Pyjo.Cache - Naive in-memory cache¶
from Pyjo.Cache import Cache
cache = Cache(max_keys=50)
cache.set('foo', 'bar')
foo = cache.get('foo')
# Or import the module, as in Google Python Style Guide
import Pyjo.Cache
cache = Pyjo.Cache.new(max_keys=50)
cache.set('foo', 'bar')
foo = cache.get('foo')
Pyjo.Cache is a naive in-memory cache with size limits.
See also¶
Pyjoyment, https://mojolicious.org.
Ported from Mojo::Cache of Mojolicious 9.49.
- class Pyjo.Cache.Pyjo_Cache(max_keys: int = 100)[source]¶
Pyjo.Cacheinherits all methods fromPyjo.Baseand implements the following new ones.- max_keys¶
max = cache.max_keys cache.max_keys = 50
Maximum number of cache keys, defaults to
100. Setting the value to0will disable caching.