
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
aiolrucache
Advanced tools
An asyncio LRU cache with TTL support for Python 3.14+.
pip install aiolrucache
@lru_cache)import asyncio
from aiolrucache import AsyncLRU
async def main():
cache = AsyncLRU(max_size=128, ttl=3600.0) # 1 hour TTL
await cache.set("key", {"data": "value"})
result = await cache.get("key")
async with AsyncLRU(max_size=64) as cache:
await cache.set("foo", "bar")
print(await cache.get("foo"))
asyncio.run(main())
from aiolrucache import alru_cache, lru_cache
# Async
@alru_cache(max_size=64, ttl=1800.0)
async def fetch_data(url: str) -> dict:
# Expensive async operation
...
# Sync
@lru_cache(max_size=128)
def expensive_computation(n: int) -> int:
...
class AsyncLRU[K, V]:
def __init__(self, max_size: int, ttl: float | None = None) -> None:
"""
Args:
max_size: Maximum number of entries (required, must be positive)
ttl: Time-to-live in seconds (optional, None = no expiry)
"""
async def get(self, key: K) -> V | None: ...
async def set(self, key: K, value: V) -> None: ...
async def clear(self) -> None: ...
async def aclose(self) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, key: K) -> bool: ...
def info(self) -> dict: ...
@alru_cache(max_size: int = 128, *, ttl: float | None = None)
async def cached_func(arg: ArgType) -> ReturnType: ...
# Methods added to decorated function:
cached_func.cache_clear() # Clear the cache
cached_func.cache_info() # dict with max_size, ttl, size
Same API as @alru_cache but for sync functions.
# Install dev dependencies
uv sync --extra dev
# Run tests
pytest
# Run linter
ruff check src tests
# Run type checker
uvx ty check src
MIT
FAQs
An asyncio LRU cache with TTL support
We found that aiolrucache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.