Config
mongo_ops.cache.config
Summary
Cache configuration.
Classes
CacheConfig
dataclass
Configuration for the cached repository layer.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled |
bool
|
Whether caching is active for the repository. |
backend |
Literal['memory', 'redis']
|
Which backend to use. Defaults to "memory". |
redis_client |
Optional[Redis]
|
Redis client required when backend is "redis". |
default_ttl |
int
|
Default time-to-live for cached entries, in seconds. |
max_entries |
int
|
Maximum entries for the in-memory backend. |
key_prefix |
str
|
Prefix applied to cache keys; defaults to the collection name when empty. |
cleanup_interval |
int
|
Interval (seconds) for the in-memory expiry sweep. |
Functions
__post_init__
Validate backend/redis consistency.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the backend is "redis" and no client is given. |
ImportError
|
If the redis package is not installed. |