Permalink
Browse files

Version bump

  • Loading branch information...
1 parent 2aec41c commit bf5f7864cb5797ec546595582421c9d80f8515a5 @mnunberg committed Feb 14, 2012
Showing with 60 additions and 60 deletions.
  1. +41 −41 lib/Couchbase/Client.pm
  2. +19 −19 lib/Couchbase/Client/Async.pm
View
82 lib/Couchbase/Client.pm
@@ -2,7 +2,7 @@ package Couchbase::Client;
BEGIN {
require XSLoader;
- our $VERSION = '0.10_0';
+ our $VERSION = '0.11_0';
XSLoader::load(__PACKAGE__, $VERSION);
}
@@ -30,22 +30,22 @@ use Array::Assign;
sub _make_conversion_settings {
my ($arglist,$options) = @_;
my $flags = 0;
-
-
+
+
$arglist->[CTORIDX_MYFLAGS] ||= 0;
-
+
if($options->{dereference_scalar_ref}) {
$arglist->[CTORIDX_MYFLAGS] |= fDEREF_RVPV;
}
-
+
if(exists $options->{deconversion}) {
if(! delete $options->{deconversion}) {
return;
}
} else {
$flags |= fDECONVERT;
}
-
+
if(exists $options->{compress_threshold}) {
my $compress_threshold = delete $options->{compress_threshold};
$compress_threshold =
@@ -56,59 +56,59 @@ sub _make_conversion_settings {
$flags |= fUSE_COMPRESSION;
}
}
-
+
my $meth_comp;
if(exists $options->{compress_methods}) {
$meth_comp = delete $options->{compress_methods};
} elsif($have_zlib) {
$meth_comp = [ sub { ${$_[1]} = Compress::Zlib::memGzip(${$_[0]}) },
sub { ${$_[1]} = Compress::Zlib::memGunzip(${$_[0]}) }]
}
-
+
if(defined $meth_comp) {
$arglist->[CTORIDX_COMP_METHODS] = $meth_comp;
}
-
+
my $meth_serialize = 0;
if(exists $options->{serialize_methods}) {
$meth_serialize = delete $options->{serialize_methods};
}
-
+
if($meth_serialize == 0 && $have_storable) {
$meth_serialize = [ \&Storable::freeze, \&Storable::thaw ];
}
-
+
if($meth_serialize) {
$flags |= fUSE_STORABLE;
$arglist->[CTORIDX_SERIALIZE_METHODS] = $meth_serialize;
}
-
+
$arglist->[CTORIDX_MYFLAGS] |= $flags;
}
sub _MkCtorIDX {
my $opts = shift;
-
+
my @arglist;
my $server = delete $opts->{server} or die "Must have server";
arry_assign_i(@arglist,
CTORIDX_SERVERS, $server,
CTORIDX_USERNAME, delete $opts->{username},
CTORIDX_PASSWORD, delete $opts->{password},
CTORIDX_BUCKET, delete $opts->{bucket});
-
+
_make_conversion_settings(\@arglist, $opts);
-
+
my $tmp = delete $opts->{io_timeout} ||
delete $opts->{select_timeout} ||
delete $opts->{connect_timeout} ||
delete $opts->{timeout};
-
+
$tmp ||= 2.5;
$arglist[CTORIDX_TIMEOUT] = $tmp if defined $tmp;
$arglist[CTORIDX_NO_CONNECT] = delete $opts->{no_init_connect};
-
-
+
+
if(keys %$opts) {
warn sprintf("Unused keys (%s) in constructor",
join(", ", keys %$opts));
@@ -136,13 +136,13 @@ sub new {
} else {
die("Must have server or servers");
}
-
+
my $connected_ok;
my $no_init_connect = $opts->{no_init_connect};
my $self;
-
+
my @all_errors;
-
+
my $privopts;
while(!$connected_ok && (my $server = shift @$server_list)) {
$opts->{server} = $server;
@@ -171,7 +171,7 @@ sub new {
}
@{$self->get_errors} = @all_errors;
return $self;
-
+
}
#This is called from within C to record our stats:
@@ -217,53 +217,53 @@ in a non-underscore release in the near future.
use Couchbase::Client;
use Couchbase::Client::Errors;
-
+
my $client = Couchbase::Client->new({
server => 'localhost:8091',
username => 'some_user',
password => 'secret',
bucket => 'my_bucket'
});
-
+
Possible connection errors:
foreach my $err (@{$client->get_errors}) {
my ($errnum,$errstr) = @$err;
warn("Trouble ahead! Couchbase client says: $errstr.");
}
my $opret;
-
+
Simple get and set:
$opret = $client->set(Hello => "World", 3600);
if(!$opret->is_ok) {
warn("Couldn't set 'Hello': ". $opret->errstr);
}
-
+
$opret = $client->get("Hello");
if($opret->value) {
printf("Got %s for 'Hello'\n", $opret->value);
} else {
warn("Couldn't get value for 'Hello': ". $opret->errstr);
}
-
+
Update expiration:
#make 'Hello' entry expire in 120 seconds
$client->touch("Hello", 120);
-
+
Atomic CAS
$opret = $client->get("Hello");
if($opret->value && $opret->value != "Planet") {
$opret = $client->cas(Hello => 'Planet', $opret->cas);
-
+
#check if atomic set was OK:
if(!$opret->is_ok) {
warn("Couldn't update: ".$opret->errstr);
}
}
-
+
=head2 DESCRIPTION
<Couchbase::Client> is the client for couchbase (http://www.couchbase.org),
@@ -460,7 +460,7 @@ and L</get> will then pretend that the key hasn't been found.
deconversion => 1
(default: deconversion => 1)
-
+
Controls whether I<de>-compression and I<de>-serialization are performed on
apparently serialized or compressed values.
@@ -470,7 +470,7 @@ Default is enabled.
dereference_scalar_ref => 1
(default: dereference_scalar_ref => 0)
-
+
Controls whether a SCALAR reference is 'serialized' as normal via storable,
or whether it should be dereferenced, and its underlying string used as a plain
scalar value.
@@ -526,7 +526,7 @@ The <cas> argument is retrieved as such:
my $opret = $client->get("Key");
$client->set("Key", "Value", $opret->cas);
-
+
The last argument is the expiration offset as documented in L</set>
=head3 touch(key, expiry)
@@ -598,7 +598,7 @@ calling convention of the non-multi command variant.
Thus, where you would do:
$rv = $o->foo($arg1, $arg2, $arg3)
-
+
The C<_multi> version would be
$rvs = $o->foo_multi(
@@ -610,15 +610,15 @@ The n-tuples themselves may either be grouped into a 'list', or an array referen
itself:
my @arglist = map { [$h->{key}, $k->{value} ] };
-
+
$o->set(@arglist);
-
+
#the same as:
-
+
$o->set( [ map [ { $h->{key}, $h->{value } ] }] );
-
+
#and the same as:
-
+
$o->set(map{ [$h->{key}, $h->{value}] });
@@ -733,7 +733,7 @@ The return value is an arrayref of arrayrefs in the following format:
[$errnum, $errstr],
...
]
-
+
Modifications to the arrayref returned by C<get_errors> will be reflected in
future calls to this function, until a new operation is performed and the error
stack is cleared.
@@ -753,7 +753,7 @@ The return format is as so:
'key_name' => 'key_value',
...
},
-
+
...
}
View
38 lib/Couchbase/Client/Async.pm
@@ -1,7 +1,7 @@
package Couchbase::Client::Async;
use strict;
use warnings;
-our $VERSION = '0.10_0';
+our $VERSION = '0.11_0';
require XSLoader;
XSLoader::load('Couchbase::Client', $VERSION);
use Couchbase::Client;
@@ -20,23 +20,23 @@ sub new {
);
my %async_opts;
@async_opts{@async_keys} = delete @{$options}{@async_keys};
-
+
my $arglist = Couchbase::Client::_MkCtorIDX($options);
-
+
$arglist->[CTORIDX_CBEVMOD] = delete $async_opts{cb_update_event}
and
$arglist->[CTORIDX_CBERR] = delete $async_opts{cb_error}
and
$arglist->[CTORIDX_CBWAITDONE] = delete $async_opts{cb_waitdone}
and
$arglist->[CTORIDX_CBTIMERMOD] = delete $async_opts{cb_update_timer}
-
+
or die "We require update_event, error, and wait_done callbacks";
-
+
if($async_opts{bless_events}) {
$arglist->[CTORIDX_BLESS_EVENT] = 1;
}
-
+
my $o = $cls->construct($arglist);
return $o;
}
@@ -56,7 +56,7 @@ foreach my $subname (qw(
*{$subname} = sub {
my ($self,@args) = @_;
my $base = $self->_get_base_rv;
-
+
@_ = ($base, @args);
goto &{"Couchbase::Client::$subname"};
};
@@ -108,13 +108,13 @@ constructor.
cb_update_event => sub {
my ($evdata,$action,$flags) = @_;
-
+
if(ref($evdata) ne "Couchbase::Client::Event") {
bless $evdata, "Couchbase::Client::Event";
}
...
};
-
+
This callback is invoked to update and/or modify events. It receives three
arguments.
@@ -158,10 +158,10 @@ C<fd> is closed or changed.
The first time an event is created, the C<dupfh> field will be undef, and
the callback should check for this creation, and if true, create a new one,
using the following idiom:
-
+
open my $dupfh, ">&", $evdata->fd;
$evdata->dupfh($dupfh);
-
+
the C<dupfh> field will persist the next time the C<cb_update_event> callback
is invoked.
@@ -198,7 +198,7 @@ contains the active events before this callback was invoked. Thus, instead of
explicitly disabling all non-listed events, one can do the following:
my $events_to_delete = $evdata->old_flags & (~$flags);
-
+
and only handle the events mentioned in C<$events_to_delete>
The C<old_flags> will be set to the current value of C<$flags> once the callback
@@ -240,7 +240,7 @@ For the C<EVACTION_WATCH> event, the implementation must have the event loop
dispatch to a function that will ultimately do something of the following:
Couchbase::Client::Async->HaveEvent($which, $evdata->opaque);
-
+
Where the C<$which> argument contains the event which ocurred (either
C<COUCHBASE_READ_EVENT> or C<COUCHBASE_WRITE_EVENT>), and the C<opaque> argument
being the C<opaque> field passed in (this) callback.
@@ -252,13 +252,13 @@ See L</HaveEvent> for more details.
cb_update_timer => sub {
my ($evdata,$action,$usecs) = @_;
my $timer_id = $evdata->pl_data;
-
+
if($action == EVACTION_WATCH) {
if(defined $timer_id) {
reschedule_timer($timer_id, $usecs / (1000*1000),
callback => 'Couchbase::Client::Async::HaveData',
args => ['Couchbase::Client::Async', 0, $evdata->opaque]);
-
+
} else {
$timer_id = schedule_timer(
$usecs / (1000*1000) ...
@@ -268,7 +268,7 @@ See L</HaveEvent> for more details.
delete_timer($evdata->pl_data);
}
};
-
+
This callback is invoked to schedule an interval timer.
It is passed three arguments:
@@ -327,7 +327,7 @@ ready. It is a package method and not an object method.
It is called as so:
Couchbase::Client::Async->HaveEvent($flags, $opaque);
-
+
The C<$flags> argument is only relevant for I/O events (and not timers). The
C<$opaque> argument must be supplied and contains an internal pointer to a private
C data structure. RTFSC if you really wish to know what's inside there.
@@ -359,7 +359,7 @@ Issue couchbase command(s).
CBTYPE_*,
[....],
);
-
+
Pretty complicated, eh?
It was the only sane way to have a single request function without limiting the
@@ -427,4 +427,4 @@ fields are provided, and which commands they apply to.
It may help to use my L<Array::Assign> module to deal with the fields in the
array.
-=back
+=back

0 comments on commit bf5f786

Please sign in to comment.