Zing::Store::Redis - Redis Storage
Redis Storage Abstraction
use Zing::Store::Redis; use Zing::Encoder::Dump; my $redis = Zing::Store::Redis->new( encoder => Zing::Encoder::Dump->new ); # $redis->drop;
This package provides a Redis storage adapter for use with data persistence abstractions.
This package inherits behaviors from:
Zing::Store
This package uses type constraints from:
Zing::Types
This package has the following attributes:
client(InstanceOf["Redis"])
This attribute is read-only, accepts (InstanceOf["Redis"]) values, and is optional.
(InstanceOf["Redis"])
This package implements the following methods:
decode(Str $data) : HashRef
The decode method decodes the JSON data provided and returns the data as a hashref.
# given: synopsis $redis->decode('{"status"=>"ok"}');
drop(Str $key) : Int
The drop method removes (drops) the item from the datastore.
# given: synopsis $redis->drop('zing:main:global:model:temp');
encode(HashRef $data) : Str
The encode method encodes and returns the data provided as JSON.
# given: synopsis $redis->encode({ status => 'ok' });
keys(Str @keys) : ArrayRef[Str]
The keys method returns a list of keys under the namespace of the datastore or provided key.
# given: synopsis my $keys = $redis->keys('zing:main:global:model:temp');
# given: synopsis $redis->send('zing:main:global:model:temp', { status => 'ok' }); my $keys = $redis->keys('zing:main:global:model:temp');
lpull(Str $key) : Maybe[HashRef]
The lpull method pops data off of the top of a list in the datastore.
# given: synopsis $redis->lpull('zing:main:global:model:items');
# given: synopsis $redis->rpush('zing:main:global:model:items', { status => 'ok' }); $redis->lpull('zing:main:global:model:items');
lpush(Str $key, HashRef $val) : Int
The lpush method pushed data onto the top of a list in the datastore.
# given: synopsis $redis->lpush('zing:main:global:model:items', { status => '1' });
# given: synopsis $redis->lpush('zing:main:global:model:items', { status => '0' });
recv(Str $key) : Maybe[HashRef]
The recv method fetches and returns data from the datastore by its key.
# given: synopsis $redis->recv('zing:main:global:model:temp');
# given: synopsis $redis->send('zing:main:global:model:temp', { status => 'ok' }); $redis->recv('zing:main:global:model:temp');
rpull(Str $key) : Maybe[HashRef]
The rpull method pops data off of the bottom of a list in the datastore.
# given: synopsis $redis->rpull('zing:main:global:model:items');
# given: synopsis $redis->rpush('zing:main:global:model:items', { status => 1 }); $redis->rpush('zing:main:global:model:items', { status => 2 }); $redis->rpull('zing:main:global:model:items');
rpush(Str $key, HashRef $val) : Int
The rpush method pushed data onto the bottom of a list in the datastore.
# given: synopsis $redis->rpush('zing:main:global:model:items', { status => 'ok' });
# given: synopsis $redis->rpush('zing:main:global:model:items', { status => 'ok' }); $redis->rpush('zing:main:global:model:items', { status => 'ok' });
send(Str $key, HashRef $val) : Str
The send method commits data to the datastore with its key and returns truthy.
# given: synopsis $redis->send('zing:main:global:model:temp', { status => 'ok' });
size(Str $key) : Int
The size method returns the size of a list in the datastore.
# given: synopsis my $size = $redis->size('zing:main:global:model:items');
# given: synopsis $redis->rpush('zing:main:global:model:items', { status => 'ok' }); my $size = $redis->size('zing:main:global:model:items');
slot(Str $key, Int $pos) : Maybe[HashRef]
The slot method returns the data from a list in the datastore by its index.
# given: synopsis my $model = $redis->slot('zing:main:global:model:items', 0);
# given: synopsis $redis->rpush('zing:main:global:model:items', { status => 'ok' }); my $model = $redis->slot('zing:main:global:model:items', 0);
test(Str $key) : Int
The test method returns truthy if the specific key (or datastore) exists.
# given: synopsis $redis->rpush('zing:main:global:model:items', { status => 'ok' }); $redis->test('zing:main:global:model:items');
# given: synopsis $redis->drop('zing:main:global:model:items'); $redis->test('zing:main:global:model:items');
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Zing::Store::Redis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Zing::Store::Redis
CPAN shell
perl -MCPAN -e shell install Zing::Store::Redis
For more information on module installation, please visit the detailed CPAN module installation guide.