Slovo::Cache - Naive in-memory cache
use Slovo::Cache; my $cache = Slovo::Cache->new(max_keys => 50, prefix=>'baz'); $cache->set(foo => 'bar'); my $foo = $cache->get('foo'); # bar
Slovo::Cache is a naive in-memory cache with size limits and key prefixes. It is a modification of Mojo::Cache. It can set a prefix to the keys. This is how we cache templates to support different themes per domain.
Slovo::Cache implements the following attributes.
The prefix which will be used for each key. Defaults to empty string. It is reset in "around_dispatch" in Slovo to set different namespace for cached templates per domain.
my $max = $cache->max_keys; $cache = $cache->max_keys(50);
Maximum number of cache keys, defaults to 111. Setting the value to 0 will disable caching.
111
0
Mojo::Cache inherits all methods from Mojo::Base and implements the following new ones.
my $value = $cache->get('foo');
Get cached value.
$cache = $cache->set(foo => 'bar');
Set cached value.
"around_dispatch" in Slovo, Mojolicious, Mojolicious::Guides, https://mojolicious.org.
To install Slovo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Slovo
CPAN shell
perl -MCPAN -e shell install Slovo
For more information on module installation, please visit the detailed CPAN module installation guide.