The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

   AnyEvent::KVStore::Driver -- The Driver role for AnyEvent::KVStore

VERSION

   0.1.2

SYNOPSIS

    package AnyEvent::KVStore::Test;

    use strict;
    use warnings;
    use Moose; # or Moo
    with 'AnyEvent::KVStore::Driver';

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

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

DESCRIPTION

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

Lifecycle

Drivers are instantiated with the 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.

Required Methods

$string = $store->read($key) (prototype $$)

This method MUST read and return the value stored by key $key

$bool = $store->exists($key) (prototype $$)

This method MUST check to see if the key exists and return TRUE if so, FALSE otherwise.

@strings = $store->list($prefix) (prototype $$)

This method MUST take in a string, and return a list of strings of all keys in the store beginning with $prefix.

$success = $store->write($key, $value) (prototype $$$)

This method MUST take two strings, and write the second to the key/value store with the first argument being the key, and the second being the value.

If the value is undef the key must be deleted.

void $store->watch($prefix, $callback) (prototype ($&)

Methods SHOULD use Perl prototypes, particularly for Watch so that blocks can be passed in as well as coderefs.

OTHER INFO

For copyright, licensing and copying, bog tracker and other items, see the POD for the AnyEvent::KVStore module.