File Coverage

blib/lib/AnyEvent/KVStore/Driver.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             AnyEvent::KVStore::Driver -- The Driver role for AnyEvent::KVStore
4              
5             =head1 VERSION
6              
7             0.1.2
8              
9             =cut
10              
11             package AnyEvent::KVStore::Driver;
12             our $VERSION = '0.1.1';
13 3     3   111248 use strict;
  3         7  
  3         145  
14 3     3   20 use warnings;
  3         7  
  3         200  
15 3     3   55 use Moo::Role;
  3         7  
  3         24  
16             requires qw(read exists list write watch);
17              
18             =head1 SYNOPSIS
19              
20             package AnyEvent::KVStore::Test;
21              
22             use strict;
23             use warnings;
24             use Moose; # or Moo
25             with 'AnyEvent::KVStore::Driver';
26              
27             # implement read, exists, list, write, and watch.
28            
29             # Then, elsewhere:
30              
31             my $kvstore = AnyEvent::KVStore->new('test', {});
32             ...
33              
34             =head1 DESCRIPTION
35              
36             This module defines and provides the interface guarantees for the drivers for
37             the L framework. If you are writing a driver you will want
38             to review this section carefully.
39              
40             =head2 Lifecycle
41              
42             Drivers are instantiated with the C function and persist until garbage
43             collection removes them. Usually connection will be lazily created based on
44             the configuration hash provided since Moo usually creates the constructor for
45             us.
46              
47             =head2 Required Methods
48              
49             =over
50              
51             =item $string = $store->read($key) (prototype $$)
52              
53             This method MUST read and return the value stored by key C<$key>
54              
55             =item $bool = $store->exists($key) (prototype $$)
56              
57             This method MUST check to see if the key exists and return TRUE if so, FALSE
58             otherwise.
59              
60             =item @strings = $store->list($prefix) (prototype $$)
61              
62             This method MUST take in a string, and return a list of strings of all keys
63             in the store beginning with C<$prefix>.
64              
65             =item $success = $store->write($key, $value) (prototype $$$)
66              
67             This method MUST take two strings, and write the second to the key/value store
68             with the first argument being the key, and the second being the value.
69              
70             If the value is C the key must be deleted.
71              
72             =item void $store->watch($prefix, $callback) (prototype ($&)
73              
74             =back
75              
76             Methods SHOULD use Perl prototypes, particularly for Watch so that blocks can
77             be passed in as well as coderefs.
78              
79             =head1 OTHER INFO
80              
81             For copyright, licensing and copying, bog tracker and other items, see the POD
82             for the C module.
83              
84             =cut
85              
86             1;