1Mojo::Cache(3)        User Contributed Perl Documentation       Mojo::Cache(3)
2
3
4

NAME

6       Mojo::Cache - Naive in-memory cache
7

SYNOPSIS

9         use Mojo::Cache;
10
11         my $cache = Mojo::Cache->new(max_keys => 50);
12         $cache->set(foo => 'bar');
13         my $foo = $cache->get('foo');
14

DESCRIPTION

16       Mojo::Cache is a naive in-memory cache with size limits.
17

ATTRIBUTES

19       Mojo::Cache implements the following attributes.
20
21   max_keys
22         my $max = $cache->max_keys;
23         $cache  = $cache->max_keys(50);
24
25       Maximum number of cache keys, defaults to 100. Setting the value to 0
26       will disable caching.
27

METHODS

29       Mojo::Cache inherits all methods from Mojo::Base and implements the
30       following new ones.
31
32   get
33         my $value = $cache->get('foo');
34
35       Get cached value.
36
37   set
38         $cache = $cache->set(foo => 'bar');
39
40       Set cached value.
41

SEE ALSO

43       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
44
45
46
47perl v5.36.0                      2022-07-22                    Mojo::Cache(3)
Impressum