MCE::Shared::Minidb - A fast, pure-Perl in-memory data structure store
This document describes MCE::Shared::Minidb version 1.699_009
# non-shared use MCE::Shared::Minidb; my $db = MCE::Shared::Minidb->new(); # shared use MCE::Shared; my $db = MCE::Shared->minidb(); # HoH $db->hset('key1', 'f1', 'foo'); $db->hset('key2', 'f1', 'bar', 'f2', 'baz'); $val = $db->hget('key2', 'f2'); # 'baz' # HoA $db->lset('key1', 0, 'foo'); $db->lset('key2', 0, 'bar', 1, 'baz'); $val = $db->lget('key2', 1); # 'baz'
A simplistic in-memory NoSQL-like DB for use with MCE::Shared. Although several methods resemble the Redis API, it is not the intent for this module to become 100% compatible with it.
Redis
Several methods in MCE::Shared::Minidb receive a query string argument. The string is quoteless. Basically, any quotes inside the string will be treated literally.
MCE::Shared::Minidb
Search capability: =~ !~ eq ne lt le gt ge == != < <= > >= "key =~ /pattern/i :AND field =~ /pattern/i" "key =~ /pattern/i :AND index =~ /pattern/i" "key =~ /pattern/i :AND field eq foo bar" # address eq foo bar "index eq foo baz :OR key !~ /pattern/i" # 9 eq foo baz key means to match against keys in the hash (H)oH or (H)oA field means to match against HoH->{key}->{field}; e.g. address index means to match against HoA->{key}->[index]; e.g. 9 Keys in hash may have spaces, but not in field names Ho(H). :AND(s) and :OR(s) mixed together is not supported.
The select_aref and select_href methods receive a select string allowing one to specify field names and sort directives.
select_aref
select_href
"f1 f2 f3 :WHERE f4 > 20 :AND key =~ /foo/ :ORDER BY f5 DESC ALPHA" "f1 f2 f3 :where f4 > 20 :and key =~ /foo/ :order by f5 desc alpha" "f5 f1 f2 :WHERE fN > 40 :AND key =~ /bar/ :ORDER BY key ALPHA" "f5 f1 f2 :where fN > 40 :and key =~ /bar/ :order by key alpha" "f5 f1 f2 :WHERE fN > 40 :AND key =~ /bar/" "f5 f1 f2 :where fN > 40 :and key =~ /bar/" "f5 f1 f2"
The shorter form without field names is allowed for HoA.
"4 > 20 :and key =~ /baz/" 4 is the array index
To be completed before the final 1.700 release.
Constructs an empty Minidb object.
Minidb
Dumps the content to a file.
Restores the content from a file.
Returns a code reference that returns a single key => href pair.
Returns a code reference that returns a single key => value pair.
Returns a code reference that returns a single key => aref pair.
Returns [ key, aref ] pairs.
Returns [ key, href ] pairs.
The implementation is inspired by various Redis Hash/List primitives at http://redis.io/commands.
MCE, MCE::Core, MCE::Shared
Mario E. Roy, <marioeroy AT gmail DOT com>
To install MCE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MCE
CPAN shell
perl -MCPAN -e shell install MCE
For more information on module installation, please visit the detailed CPAN module installation guide.