NAME
Slovo::Cache - Naive in-memory cache
SYNOPSIS
use Slovo::Cache;
my $cache = Slovo::Cache->new(max_keys => 50, prefix=>'baz');
$cache->set(foo => 'bar');
my $foo = $cache->get('foo'); # bar
DESCRIPTION
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.
ATTRIBUTES
Slovo::Cache implements the following attributes.
key_prefix
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.
max_keys
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.
METHODS
Mojo::Cache inherits all methods from Mojo::Base and implements the following new ones.
get
my $value = $cache->get('foo');
Get cached value.
set
$cache = $cache->set(foo => 'bar');
Set cached value.
SEE ALSO
"around_dispatch" in Slovo, Mojolicious, Mojolicious::Guides, https://mojolicious.org.