use strict;
use warnings;
use Couchbase;
use Couchbase::Bucket;
use Couchbase::Document;
use Time::HiRes qw(gettimeofday);
use Data::Dumper;

sub stamp { my ($seconds, $microseconds) = gettimeofday; return "[$seconds.$microseconds] "; }

my $bucket;

warn stamp()."Connecting...";
eval {
   $bucket =  Couchbase::Bucket->new('couchbase://couchbase-server1,couchbase-server2/bucketname?detailed_errcodes=1&bootstrap_on=http&http_urlmode=2&config_total_timeout=12.0&config_node_timeout=6.0');
} or do {
   warn stamp(). "Can't connect";
   exit;
};
warn stamp()."connected";

my $key = 'LOLxDrotflLMAO_manual';

my $doc = Couchbase::Document->new($key);
$doc->value({'a'=> 'xcd'});
$doc->expiry(60);

warn stamp()."Inserting $key";
$bucket->insert($doc);

if ($doc->is_ok()) {
   warn stamp()."inserted $key";
} else {
   warn stamp(). "error ".$doc->errstr;
}
