Mojo::Cache − Naive in−memory cache
use Mojo::Cache;
my $cache = Mojo::Cache−>new(max_keys => 50);
$cache−>set(foo => 'bar');
my $foo = $cache−>get('foo');
Mojo::Cache is a naive in-memory cache with size limits.
Mojo::Cache implements the following attributes.
my $max =
$cache−>max_keys;
$cache = $cache−>max_keys(50);
Maximum number of cache keys, defaults to 100. Setting the value to 0 will disable caching.
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.
Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.