MemoryCache¶
-
class
privex.helpers.cache.MemoryCache.
MemoryCache
(*args, enter_reconnect: Optional[bool] = None, exit_close: Optional[bool] = None, **kwargs)[source]¶ A very basic cache adapter which implements
CacheAdapter
- stores the cache in memory using the static attribute__CACHE
As the cache is simply stored in memory, any python object can be cached without needing any form of serialization.
Fully supports cache expiration.
Basic Usage:
>>> from time import sleep >>> c = MemoryCache() >>> c.set('test:example', 'hello world', timeout=60) >>> c.get('test:example') 'hello world' >>> sleep(60) >>> c.get('test:example', 'NOT FOUND') 'NOT FOUND'
Methods¶
Methods
|
Return the value of cache key |
|
Attempt to return the value of |
|
Remove one or more keys from the cache. |
|
Set the cache key |
|
Update the timeout for a given |