Inmemory Cache¶
inmemory ¶
Classes¶
TTLEntry ¶
InmemoryCache ¶
InmemoryCache(*, key_builder: KeyBuilder, cache_type: Literal['lru', 'lfu', 'ttl', 'fifo'] = 'lru', maxsize: int = 1000, default_ttl: int = 300, negative_ttl: int = 60)
Bases: KVCache
Initialize InmemoryCache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_builder | KeyBuilder | KeyBuilder instance for building cache keys | required |
cache_type | Literal['lru', 'lfu', 'ttl', 'fifo'] | Type of cache strategy ('lru', 'lfu', 'ttl', 'fifo') | 'lru' |
maxsize | int | Maximum number of items in cache | 1000 |
default_ttl | int | Default TTL in seconds for cache entries | 300 |
negative_ttl | int | TTL in seconds for negative cache entries | 60 |
Source code in audex/lib/cache/inmemory.py
Attributes¶
Functions¶
set_negative async ¶
Store cache miss marker to prevent cache penetration.
Source code in audex/lib/cache/inmemory.py
keys async ¶
get async ¶
Get value from cache, return default if not found.
Source code in audex/lib/cache/inmemory.py
setdefault async ¶
Get value or set and return default if key doesn't exist.
Source code in audex/lib/cache/inmemory.py
clear async ¶
Clear all cache entries with the configured prefix.
Source code in audex/lib/cache/inmemory.py
pop async ¶
Remove and return value, or return default if not found.
Source code in audex/lib/cache/inmemory.py
popitem async ¶
Remove and return an arbitrary (key, value) pair.
Source code in audex/lib/cache/inmemory.py
set async ¶
setx async ¶
Set a key-value pair with optional TTL.
Source code in audex/lib/cache/inmemory.py
ttl async ¶
Get TTL for a key.
Source code in audex/lib/cache/inmemory.py
expire async ¶
Set or remove expiration for a key.
Source code in audex/lib/cache/inmemory.py
incr async ¶
Increment a key's value.
Source code in audex/lib/cache/inmemory.py
decr async ¶
values async ¶
Return all cache values.
Source code in audex/lib/cache/inmemory.py
items async ¶
Return all cache items as (key, value) pairs.
Source code in audex/lib/cache/inmemory.py
init async ¶
close async ¶
Close cache and cleanup resources.
Source code in audex/lib/cache/inmemory.py
options: show_root_heading: true show_source: true heading_level: 2 members_order: source show_signature_annotations: true separate_signature: true