Skip to content

cattle_grid.extensions.examples.cache

This cache stores objects temporally in a key value database

Sample configuration

cattle_grid.toml
[[extensions]]
module = "cattle_grid.extensions.examples.cache"
lookup_order = 4
config = { connection_url = "redis://cattle_grid_redis", duration = 3600 }

The duration is expressed in seconds.

config

CacheConfiguration

Bases: BaseModel

Parameters:

Name Type Description Default
connection_url str
'redis://localhost:6379'
duration int
3600
Source code in cattle_grid/extensions/examples/cache/config.py
4
5
6
7
8
9
class CacheConfiguration(BaseModel):
    connection_url: str = Field(default="redis://localhost:6379")
    """Connection url to the key value instance, e.g. redis"""

    duration: int = Field(default=3600)
    """Duration to cache in second"""

connection_url = Field(default='redis://localhost:6379') class-attribute instance-attribute

Connection url to the key value instance, e.g. redis

duration = Field(default=3600) class-attribute instance-attribute

Duration to cache in second

dependencies

CacheClient = Annotated[redis.Redis, Depends(get_cache)] module-attribute

The cache client

CacheConfig = Annotated[CacheConfiguration, Depends(get_config)] module-attribute

The configuration object passed when instantiating the extension