NAME
Zing::Store::Hash - Hash Storage
ABSTRACT
Hash Storage Abstraction
SYNOPSIS
use
Zing::Store::Hash;
use
Zing::Encoder::Dump;
my
$hash
= Zing::Store::Hash->new(
encoder
=> Zing::Encoder::Dump->new
);
# $hash->drop;
DESCRIPTION
This package provides an in-memory (only) storage adapter for use with data persistence abstractions.
INHERITS
This package inherits behaviors from:
LIBRARIES
This package uses type constraints from:
METHODS
This package implements the following methods:
decode
decode(Str
$data
) : HashRef
The decode method decodes the JSON data provided and returns the data as a hashref.
drop
drop(Str
$key
) : Int
The drop method removes (drops) the item from the datastore.
encode
encode(HashRef
$data
) : Str
The encode method encodes and returns the data provided as JSON.
keys
keys
(Str
@keys
) : ArrayRef[Str]
The keys method returns a list of keys under the namespace of the datastore or provided key.
- keys example #2
-
# given: synopsis
$hash
->
send
(
'zing:main:global:model:temp'
, {
status
=>
'ok'
});
my
$keys
=
$hash
->
keys
(
'zing:main:global:model:temp'
);
lpull
lpull(Str
$key
) : Maybe[HashRef]
The lpull method pops data off of the top of a list in the datastore.
- lpull example #2
-
# given: synopsis
$hash
->rpush(
'zing:main:global:model:items'
, {
status
=>
'ok'
});
$hash
->lpull(
'zing:main:global:model:items'
);
lpush
lpush(Str
$key
, HashRef
$val
) : Int
The lpush method pushed data onto the top of a list in the datastore.
recv
recv
(Str
$key
) : Maybe[HashRef]
The recv method fetches and returns data from the datastore by its key.
- recv example #2
-
# given: synopsis
$hash
->
send
(
'zing:main:global:model:temp'
, {
status
=>
'ok'
});
$hash
->
recv
(
'zing:main:global:model:temp'
);
rpull
rpull(Str
$key
) : Maybe[HashRef]
The rpull method pops data off of the bottom of a list in the datastore.
- rpull example #2
-
# given: synopsis
$hash
->rpush(
'zing:main:global:model:items'
, {
status
=> 1 });
$hash
->rpush(
'zing:main:global:model:items'
, {
status
=> 2 });
$hash
->rpull(
'zing:main:global:model:items'
);
rpush
rpush(Str
$key
, HashRef
$val
) : Int
The rpush method pushed data onto the bottom of a list in the datastore.
- rpush example #2
-
# given: synopsis
$hash
->rpush(
'zing:main:global:model:items'
, {
status
=>
'ok'
});
$hash
->rpush(
'zing:main:global:model:items'
, {
status
=>
'ok'
});
send
send
(Str
$key
, HashRef
$val
) : Str
The send method commits data to the datastore with its key and returns truthy.
size
size(Str
$key
) : Int
The size method returns the size of a list in the datastore.
- size example #2
-
# given: synopsis
$hash
->rpush(
'zing:main:global:model:items'
, {
status
=>
'ok'
});
my
$size
=
$hash
->size(
'zing:main:global:model:items'
);
slot
slot(Str
$key
, Int
$pos
) : Maybe[HashRef]
The slot method returns the data from a list in the datastore by its index.
- slot example #2
-
# given: synopsis
$hash
->rpush(
'zing:main:global:model:items'
, {
status
=>
'ok'
});
my
$model
=
$hash
->slot(
'zing:main:global:model:items'
, 0);
test
test(Str
$key
) : Int
The test method returns truthy if the specific key (or datastore) exists.
- test example #1
-
# given: synopsis
$hash
->rpush(
'zing:main:global:model:items'
, {
status
=>
'ok'
});
$hash
->test(
'zing:main:global:model:items'
);
- test example #2
-
# given: synopsis
$hash
->drop(
'zing:main:global:model:items'
);
$hash
->test(
'zing:main:global:model:items'
);
AUTHOR
Al Newkirk, awncorp@cpan.org
LICENSE
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".