Zing::Store::Sqlite
Sqlite Storage
Sqlite Storage Abstraction
method: drop method: encode method: keys method: decode method: lpull method: lpush method: recv method: rpull method: rpush method: send method: size method: slot method: test
use Test::DB::Sqlite;
use Zing::Encoder::Dump;
use Zing::Store::Sqlite;
my $testdb = Test::DB::Sqlite->new;
my $store = Zing::Store::Sqlite->new(
  client => $testdb->create->dbh,
  encoder => Zing::Encoder::Dump->new
);
# $store->drop;Zing::Types
client: ro, opt, InstanceOf["DBI::db"]
Zing::Store
This package provides a SQLite-specific storage adapter for use with data persistence abstractions. The "client" attribute accepts a DBI object configured to connect to a DBD::SQLite backend. The ZING_DBNAME environment variable can be used to specify the database name (defaults to "zing.db"). The ZING_DBZONE environment variable can be used to specify the database table name (defaults to "entities").
The drop method removes (drops) the item from the datastore.
drop(Str $key) : Int
=example-1 drop
# given: synopsis
$store->drop('zing:main:global:model:temp');The encode method encodes and returns the data provided as JSON.
encode(HashRef $data) : Str
=example-1 encode
# given: synopsis
$store->encode({ status => 'ok' });The keys method returns a list of keys under the namespace of the datastore or provided key.
keys(Str @keys) : ArrayRef[Str]
=example-1 keys
# given: synopsis
my $keys = $store->keys('zing:main:global:model:temp');=example-2 keys
# given: synopsis
$store->send('zing:main:global:model:temp', { status => 'ok' });
my $keys = $store->keys('zing:main:global:model:temp');The rpull method pops data off of the bottom of a list in the datastore.
rpull(Str $key) : Maybe[HashRef]
=example-1 rpull
# given: synopsis
$store->rpull('zing:main:global:model:items');=example-2 rpull
# given: synopsis
$store->rpush('zing:main:global:model:items', { status => 1 });
$store->rpush('zing:main:global:model:items', { status => 2 });
$store->rpull('zing:main:global:model:items');The lpull method pops data off of the top of a list in the datastore.
lpull(Str $key) : Maybe[HashRef]
=example-1 lpull
# given: synopsis
$store->lpull('zing:main:global:model:items');=example-2 lpull
# given: synopsis
$store->rpush('zing:main:global:model:items', { status => 'ok' });
$store->lpull('zing:main:global:model:items');The rpush method pushed data onto the bottom of a list in the datastore.
rpush(Str $key, HashRef $val) : Int
=example-1 rpush
# given: synopsis
$store->rpush('zing:main:global:model:items', { status => 'ok' });=example-2 rpush
# given: synopsis
$store->rpush('zing:main:global:model:items', { status => 'ok' });
$store->rpush('zing:main:global:model:items', { status => 'ok' });The decode method decodes the JSON data provided and returns the data as a hashref.
decode(Str $data) : HashRef
=example-1 decode
# given: synopsis
$store->decode('{"status"=>"ok"}');The recv method fetches and returns data from the datastore by its key.
recv(Str $key) : Maybe[HashRef]
=example-1 recv
# given: synopsis
$store->recv('zing:main:global:model:temp');=example-2 recv
# given: synopsis
$store->send('zing:main:global:model:temp', { status => 'ok' });
$store->recv('zing:main:global:model:temp');The send method commits data to the datastore with its key and returns truthy.
send(Str $key, HashRef $val) : Str
=example-1 send
# given: synopsis
$store->send('zing:main:global:model:temp', { status => 'ok' });The size method returns the size of a list in the datastore.
size(Str $key) : Int
=example-1 size
# given: synopsis
my $size = $store->size('zing:main:global:model:items');=example-2 size
# given: synopsis
$store->rpush('zing:main:global:model:items', { status => 'ok' });
my $size = $store->size('zing:main:global:model:items');The slot method returns the data from a list in the datastore by its index.
slot(Str $key, Int $pos) : Maybe[HashRef]
=example-1 slot
# given: synopsis
my $model = $store->slot('zing:main:global:model:items', 0);=example-2 slot
# given: synopsis
$store->rpush('zing:main:global:model:items', { status => 'ok' });
my $model = $store->slot('zing:main:global:model:items', 0);The test method returns truthy if the specific key (or datastore) exists.
test(Str $key) : Int
=example-1 test
# given: synopsis
$store->rpush('zing:main:global:model:items', { status => 'ok' });
$store->test('zing:main:global:model:items');=example-2 test
# given: synopsis
$store->drop('zing:main:global:model:items');
$store->test('zing:main:global:model:items');The lpush method pushed data onto the top of a list in the datastore.
lpush(Str $key, HashRef $val) : Int
=example-1 lpush
# given: synopsis
$store->lpush('zing:main:global:model:items', { status => '1' });=example-2 lpush
# given: synopsis
$store->lpush('zing:main:global:model:items', { status => '0' });
$store->lpush('zing:main:global:model:items', { status => '0' });35 POD Errors
The following errors were encountered while parsing the POD:
- Around line 14:
- Unknown directive: =name 
- Around line 20:
- Unknown directive: =tagline 
- Around line 26:
- Unknown directive: =abstract 
- Around line 32:
- Unknown directive: =includes 
- Around line 50:
- Unknown directive: =synopsis 
- Around line 66:
- Unknown directive: =libraries 
- Around line 72:
- Unknown directive: =attributes 
- Around line 78:
- Unknown directive: =inherits 
- Around line 84:
- Unknown directive: =description 
- Around line 95:
- Unknown directive: =method 
- Around line 99:
- Unknown directive: =signature 
- Around line 111:
- Unknown directive: =method 
- Around line 115:
- Unknown directive: =signature 
- Around line 127:
- Unknown directive: =method 
- Around line 132:
- Unknown directive: =signature 
- Around line 152:
- Unknown directive: =method 
- Around line 156:
- Unknown directive: =signature 
- Around line 177:
- Unknown directive: =method 
- Around line 181:
- Unknown directive: =signature 
- Around line 201:
- Unknown directive: =method 
- Around line 205:
- Unknown directive: =signature 
- Around line 225:
- Unknown directive: =method 
- Around line 229:
- Unknown directive: =signature 
- Around line 241:
- Unknown directive: =method 
- Around line 245:
- Unknown directive: =signature 
- Around line 265:
- Unknown directive: =method 
- Around line 269:
- Unknown directive: =signature 
- Around line 281:
- Unknown directive: =method 
- Around line 285:
- Unknown directive: =signature 
- Around line 305:
- Unknown directive: =method 
- Around line 309:
- Unknown directive: =signature 
- Around line 329:
- Unknown directive: =method 
- Around line 333:
- Unknown directive: =signature 
- Around line 355:
- Unknown directive: =method 
- Around line 359:
- Unknown directive: =signature