simple_cache_backend#

class starlite.cache.simple_cache_backend.CacheObject#

Bases: object

A container class for cache data.

value: Any#

Cache data.

expiration: datetime#

Timestamp of cache.

__init__(value: Any, expiration: datetime) None#
class starlite.cache.simple_cache_backend.SimpleCacheBackend#

Bases: CacheBackendProtocol

In-memory cache backend.

__init__() None#

Initialize SimpleCacheBackend

async get(key: str) Any#

Retrieve value from cache corresponding to the given key.

Parameters:

key – name of cached value.

Returns:

Cached value or None.

async set(key: str, value: Any, expiration: int) None#

Set a value in cache for a given key with a given expiration in seconds.

Parameters:
  • key – key to cache value under.

  • value – the value to be cached.

  • expiration – expiration of cached value in seconds.

Returns:

None

async delete(key: str) None#

Remove a value from the cache for a given key.

Parameters:

key – key to be deleted from the cache.

Returns:

None