Configuration — Aquilia Documentation
Comprehensive guide and documentation for Configuration in the Aquilia framework. View API reference, examples, and implementation patterns.
Cache / Configuration Cache Configuration Configure AquilaCache via workspace integrations, typed integration dataclasses, Python-native config classes, and AQ_* environment overlays. Primary Configuration Paths from aquilia import Workspace, Integration from aquilia.integrations import CacheIntegration workspace = ( Workspace("myapp") # Dict-based API .integrate(Integration.cache( backend="redis", redis_url="redis://localhost:6379/0", default_ttl=300, serializer="json", middleware_enabled=True, middleware_default_ttl=60, )) # Typed Integration API .integrate(CacheIntegration( backend="memory", default_ttl=120, max_size=10000, eviction_policy="lru", )) ) AquilaConfig.Cache (Python-native) from aquilia.config_builders import AquilaConfig, Env class BaseEnv(AquilaConfig): class Cache(AquilaConfig.Cache): backend = Env("AQ_CACHE_BACKEND", default="memory") default_ttl = 300 max_size = 10000 eviction_policy = "lru" namespace = "default" key_prefix = "aq:" redis_url = Env("AQ_CACHE_REDIS_URL", default="redis://localhost:6379/0") Environment Mapping ConfigLoader ingests AQ_ prefixed variables and maps nested paths using double underscores: # Flat key AQ_CACHE__BACKEND=redis AQ_CACHE__DEFAULT_TTL=600 AQ_CACHE__REDIS_URL=redis://cache:6379/0 # Response cache middleware settings AQ_CACHE__MIDDLEWARE_ENABLED=true AQ_CACHE__MIDDLEWARE_DEFAULT_TTL=45 AQ_CACHE__MIDDLEWARE_STALE_WHILE_REVALIDATE=30 Configuration Precedence: environment variables have higher priority than defaults declared in Python configuration files, allowing seamless deployment adjustments. Field Reference Key Type Description ))} How Config Is Loaded from aquilia.config import ConfigLoader loader = ConfigLoader.load() cache_cfg = loader.get_cache_config() # get_cache_config() behavior: # 1) starts from built-in defaults # 2) overlays root "cache" if present # 3) falls back to "integrations.cache" if root cache is missing # 4) forces enabled=True when user cache config exists Current Behavior Notes • Cache config keys are flat (e.g. middleware_enabled), whereas the ASGI server auto-wiring routine checks nested cache.middleware dict properties when enabling CacheMiddleware . • The HMAC-signed PickleCacheSerializer requires a secret_key to decrypt payloads. Ensure this is passed during custom instantiation since the automated loader doesn't fetch it dynamically. )
Go to Homepage