onecache
Python cache for sync and async code
Decision gist · record as of 2026-08-14
Yes. OneCache is a solid choice for lightweight, decorator-based caching in Python applications. It has zero runtime dependencies, is actively maintained, supports modern Python versions (3.8–3.14), carries no security vulnerabilities, and works seamlessly with both sync and async code. Install it if you need simple LRU caching with optional TTL and don't want to manage an external cache service.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8 or later; max_mem_size parameter is ignored on PyPy due to JIT compilation.
- Low install friction with no runtime dependencies.
- Actively maintained as of 2026-02-20, tested across CPython 3.8–3.14 and PyPy 3.9 on Linux, macOS, and Windows.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
last release 2026-02-20 (175 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 725,663 downloads/mo, #5,220 on PyPI
Alternatives
Verify before relying
from onecache import CacheDecorator, AsyncCacheDecorator
@CacheDecorator(maxsize=512, ttl=None)
def my_function(x):
return x * 2
@AsyncCacheDecorator(maxsize=512)
async def my_async_function(x):
return x * 2- Performance characteristics and overhead compared to functools.lru_cache or other caching libraries.
- Thread safety guarantees when thread_safe=True is enabled.
- Behavior of refresh_ttl flag and its interaction with concurrent access patterns.
What it is and what it does
OneCache is a lightweight in-memory caching library that wraps functions with LRU (Least Recently Used) eviction and optional time-to-live expiration. It provides two decorator classes—CacheDecorator for sync functions and AsyncCacheDecorator for async coroutines—allowing you to cache function results without modifying function signatures. The cache automatically evicts the oldest entry when it reaches maxsize, and can optionally expire entries after a specified TTL in milliseconds. You can also set memory size limits and enable thread-safe locking for concurrent access.
The library is designed for straightforward use: decorate a function, configure cache size and TTL, and results are automatically cached and reused on subsequent calls with identical arguments. It supports skipping arguments from the cache key, refreshing TTL on each access, and choosing alternative cache implementations via the cache_class parameter.
Use it for
- Cache expensive database queries or API calls in web applications to reduce latency and load.
- Memoize computationally intensive calculations in data processing pipelines with automatic expiration.
- Speed up async coroutines by caching results across multiple concurrent requests with TTL-based invalidation.
- Reduce redundant function calls in long-running services where results are valid for a limited time window.
- Implement request-level or session-level caching in frameworks without external cache infrastructure.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
OneCache is a solid choice for lightweight, decorator-based caching in Python applications. It has zero runtime dependencies, is actively maintained, supports modern Python versions (3.8–3.14), carries no security vulnerabilities, and works seamlessly with both sync and async code. Install it if you need simple LRU caching with optional TTL and don't want to manage an external cache service.
Install
onecache on PyPI
Before you install
Low install friction with no runtime dependencies. Actively maintained as of 2026-02-20, tested across CPython 3.8–3.14 and PyPy 3.9 on Linux, macOS, and Windows.
Requires Python 3.8 or later; max_mem_size parameter is ignored on PyPy due to JIT compilation.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
from onecache import CacheDecorator, AsyncCacheDecorator
@CacheDecorator(maxsize=512, ttl=None)
def my_function(x):
return x * 2
@AsyncCacheDecorator(maxsize=512)
async def my_async_function(x):
return x * 2
Verify before relying
- Performance characteristics and overhead compared to functools.lru_cache or other caching libraries.
- Thread safety guarantees when thread_safe=True is enabled.
- Behavior of refresh_ttl flag and its interaction with concurrent access patterns.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 175 days since the last release |
| First released | |
| Downloads | 725,663 / month, #5,220 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: PyPy |
Evidence: onecache-0.8.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “lru cache async sync”
- onecacheOneCache provides LRU-based caching decorators for both synchronous…
- async-lruAn LRU cache decorator for async functions that deduplicates…
- cachetools-asyncProvides async-aware memoization decorators for Python asyncio…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also async-lru · cachettl · cachetools-async · cacheout · cachetools · asyncache · cache-to-disk · expiring-dict · cachebox · pytest-antilru