redis_cache_backend#
- class starlite.cache.redis_cache_backend.RedisCacheBackendConfig#
Bases:
BaseModel
Redis cache backend configuration.
- class starlite.cache.redis_cache_backend.RedisCacheBackend#
Bases:
CacheBackendProtocol
Redis-based cache backend.
- __init__(config: RedisCacheBackendConfig)#
Initialize
RedisCacheBackend
- Parameters:
config – required configuration to connect to Redis.
- async get(key: str) Any #
Retrieve a value from cache corresponding to the given key.
- Parameters:
key – name of cached value.
- Returns:
Cached value if existing else
None
.
- async set(key: str, value: Any, expiration: int) None #
Set a value in cache for a given key for a duration determined by expiration.
- Parameters:
key – key to cache
value
under.value – the value to be cached.
expiration – expiration of cached value in seconds.
Notes
expiration is in seconds.
return value is not used by Starlite internally.
- Returns:
None