Mojar::Cache - Bare-bones in-memory cache
use Mojar::Cache; my $cache = Mojar::Cache->new; $cache->set(foo => 'bar'); my $foo = $cache->get('foo');
A minimalist cache intended to be easily upgradeable to CHI.
Mojar::Cache implements the following attributes.
namespace
$cache->namespace('Admin'); $namespace = $cache->namespace;
Namespace for the cache, defaults to main.
main
#=head2 on_get_error # # my $cb = $cache->on_get_error; # $cache = $cache->on_get_error(sub { ... }); # #Callback triggered by get exception, defaults to a null sub. # #=head2 on_set_error # # my $cb = $cache->on_set_error; # $cache = $cache->on_set_error(sub { ... }); # #Callback triggered by set exception, defaults to a null sub.
on_get_error
get
on_set_error
set
my $value = $cache->get('foo');
Get cached value.
$cache = $cache->set(foo => 'bar');
Set cache value.
Mojo::Cache is beautifully simple but sometimes too barebones; CHI is the proper way to do serious cacheing but cannot be done on a small footprint. I wanted minor extensions to the former with an upgrade path to the latter.
Mojo::Cache, CHI.
To install Mojar, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojar
CPAN shell
perl -MCPAN -e shell install Mojar
For more information on module installation, please visit the detailed CPAN module installation guide.