AnyEvent-KVStore

 view release on metacpan or  search on metacpan

lib/AnyEvent/KVStore.pm  view on Meta::CPAN

    use AnyEvent::KVStore;

    my $foo = AnyEvent::KVStore->new(type => 'etcd', config => $config);
    my $val = $foo->read($key);
    $foo->write($key, $val2);

    $foo->watch($keyspace, \&process_vals);

=head1 DESCRIPTION

The AnyEventLLKVStore framework intends to be a simple, pluggable API for
abstracting away the details of key-value store integratoins in event loop for
the standard operations one is likely to experience in an event loop.

The idea is to make key-value stores reasonably pluggable for variou skinds of
operations so that when one fails to scale in one scenario, another can be used
and alaternatively, the same app can support several different stores.

The framework uses Moo (Minimalist Object Orientation) to procide the basic
interface specifications, and modules providing drivers here are expected to
use Moo for defining accessors, etc.

=head1 ACCESSORS/PROPERTIES

=head2 module

The name of the driver used.

=cut

lib/AnyEvent/KVStore/Driver.pm  view on Meta::CPAN

    # implement read, exists, list, write, and watch.
    
    # Then, elsewhere:

    my $kvstore = AnyEvent::KVStore->new('test', {});
    ...

=head1 DESCRIPTION

This module defines and provides the interface guarantees for the drivers for
the L<AnyEvent::KVStore> framework. If you are writing a driver you will want
to review this section carefully.

=head2 Lifecycle

Drivers are instantiated with the C<new()> function and persist until garbage
collection removes them.  Usually connection will be lazily created based on
the configuration hash provided since Moo usually creates the constructor for
us.

=head2 Required Methods

lib/AnyEvent/KVStore/Hash.pm  view on Meta::CPAN

   $store->write('foo', 'bar');
   $store->watch('f', sub { my ($k, $v) = @_; warn "Setting $k to $v"; });
   $store->write('far', 'over there');

=head2 DESCRIPTION

L<AnyEvent::KVStore> ships with a very simple, non-blocking key-value store for
testing, proofs of concepts, and other purposes.  This has all the advantages
and disadvantages of just storing the data in a hash table, but comes with
callback features on write.  You can use this as a glorified enriched hashtable
or you can use other modules in this framework to connect to shared key/value
stores.

Each kvstore here has its own keyspace and watch list.

=head2 Watch Behavior

C<AnyEvent::KVStore::Hash> allows for unlimited watches to be set up, and
because this key/value store is private, the callbacks are handled synchronous
to the writes.  If you want asynchronous callbacks, you can use the
C<unblock_sub> function from L<Coro>.



( run in 0.547 second using v1.01-cache-2.11-cpan-df04353d9ac )