Zing::Redis - Redis Storage
Redis Storage Abstraction
use Zing::Redis; my $redis = Zing::Redis->new; # $redis->drop;
This package provides a Redis adapter for use with data storage abstractions.
This package uses type constraints from:
Zing::Types
This package has the following attributes:
client(Redis)
This attribute is read-only, accepts (Redis) values, and is optional.
(Redis)
This package implements the following methods:
drop(Str $key) : Int
The drop method removes (drops) the item from the datastore.
# given: synopsis $redis->drop('model');
dump(HashRef $data) : Str
The dump method encodes and returns the data provided as JSON.
# given: synopsis $redis->dump({ 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('nodel');
# given: synopsis $redis->send('model', { status => 'ok' }); my $keys = $redis->keys('model');
load(Str $data) : HashRef
The load method decodes the JSON data provided and returns the data as a hashref.
# given: synopsis $redis->load('{"status":"ok"}');
pop(Str $key) : Maybe[HashRef]
The pop method pops data off of the bottom of a list in the datastore.
# given: synopsis $redis->pop('collection');
# given: synopsis $redis->push('collection', { status => 1 }); $redis->push('collection', { status => 2 }); $redis->pop('collection');
pull(Str $key) : Maybe[HashRef]
The pull method pops data off of the top of a list in the datastore.
# given: synopsis $redis->pull('collection');
# given: synopsis $redis->push('collection', { status => 'ok' }); $redis->pull('collection');
push(Str $key, HashRef $val) : Int
The push method pushed data onto the bottom of a list in the datastore.
# given: synopsis $redis->push('collection', { status => 'ok' });
# given: synopsis $redis->push('collection', { status => 'ok' }); $redis->push('collection', { status => 'ok' });
recv(Str $key) : Maybe[HashRef]
The recv method fetches and returns data from the datastore by its key.
# given: synopsis $redis->recv('model');
# given: synopsis $redis->send('model', { status => 'ok' }); $redis->recv('model');
send(Str $key, HashRef $val) : Str
The send method commits data to the datastore with its key and returns truthy.
# given: synopsis $redis->send('model', { status => 'ok' });
size(Str $key) : Int
The size method returns the size of a list in the datastore.
# given: synopsis my $size = $redis->size('collection');
# given: synopsis $redis->push('collection', { status => 'ok' }); my $size = $redis->size('collection');
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('collection', 0);
# given: synopsis $redis->push('collection', { status => 'ok' }); my $model = $redis->slot('collection', 0);
term(Str @keys) : Str
The term method generates a term (safe string) for the datastore.
# given: synopsis $redis->term('model');
test(Str $key) : Int
The test method returns truthy if the specific key (or datastore) exists.
# given: synopsis $redis->push('collection', { status => 'ok' }); $redis->test('collection');
# given: synopsis $redis->drop('collection'); $redis->test('collection');
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, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Zing
CPAN shell
perl -MCPAN -e shell install Zing
For more information on module installation, please visit the detailed CPAN module installation guide.