NAME

AnyEvent::KVStore::Hash -- A simple, hash-based Key/value store

VERSION

0.1.2

SYNOPSIS

use AnyEvent::KVStore;
my $store = AnyEvent::KVStore->new(module => 'hash', config => {});
$store->write('foo', 'bar');
$store->watch('f', sub { my ($k, $v) = @_; warn "Setting $k to $v"; });
$store->write('far', 'over there');

DESCRIPTION

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.

Watch Behavior

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 unblock_sub function from Coro.

Watches are currently indexed by the first letter of the prefix, or if no prefix is given, an empty string. Watches are then checked (and executed) in order of:

First empty prefix watches

These are run (there is no checking) in order of creation

Then the first letter of the key is used to match prefixes.

The prefixes are checked and run un order of creation here too. This may, in the future, change to be more alphabetically ordered.

This behavior is subect to change.

METHODS

Unless otherwise noted, these do exactly what the documentation in AnyEvent::KVStore and AnyEvent::KVStore::Driver suggest.

read

exists

list

write

watch

In this module, watches are run synchronously, not via AnyEvent's event loop.

If you wish to use AnyEvent's event loop, use condition variables with callbacks set and send them.

MORE INFORMATION

For information on Copyright, Licensing, Contributing, Bug trackers, etc. see the documentation of AnyEvent::KVStore, which this module is distributed as a part of.