NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #1110 most downloaded on PyPI
The fastest memoizing and caching Python library written in Rust
Last release 1 months ago
04 Sep 2026
Release timing varies
gaps range from 8 days to 2 months
Most releases are documented
notes for 52 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
3 years old
62 releases · first in 2024
Stops __traverse__ from blocking on a busy cache lock so GC cannot deadlock under that lock. A skipped pass is safe because a held lock already keeps
__traverse__ from blocking on a busy cache lock so GC cannot deadlock under that lock. A skipped pass is safe because a held lock already keeps the cache reachable; adds regression tests across all cache types. (#86).riscv64 wheel builds via RISE runners (#89).py.typed file - it used to be present and was dropped by accident (#87).Full Changelog: v6.2.6...v6.2.7
One column per month.
Add pre-built packages for windows ARM64
TTLCache/VTTCache background sweeper: Now they are using threading.Event instead a while + time.sleep (#79)_async_cached_wrapper_without_lock (#79).This is a patch release that improves cache iterators and fixes LRUCache iteration safety, with a small dependency bump and README updates.
This is a patch release that improves cache iterators and fixes LRUCache iteration safety, with a small dependency bump and README updates.
• @Malkiz223 for #74 and #76 • @chirizxc for #72
Full Changelog: v6.2.4...v6.2.5
This is a patch release that fixes two important correctness and stability issues.
This is a patch release that fixes two important correctness and stability issues.
#67 / #68: setdefault_with no longer runs the factory while holding the internal lock.
Previously, if the factory triggered a GC pass (which also needs the same lock), the whole process could freeze. The key is now looked up under the lock, the lock is released, the factory runs, and the lock is re-acquired only to insert (with a re-check).
Note: If two threads miss the same key at the same time, the factory may run twice; the first inserted value is kept and returned to both callers.
#69 / #70: Iterators returned by keys(), values(), and items() now hold a strong reference to the cache.
Previously they only kept a raw cursor, so a cache that was no longer referenced elsewhere could be freed while the iterator was still alive, causing use-after-free (access violation or silently wrong results). This is fixed for all seven cache types with no performance regression.
Full Changelog: v6.2.3...v6.2.4
Fixed several bugs related to miss counting, missing await, lock cleanup on exceptions, and cancellation handling.
Fixed several bugs related to miss counting, missing await, lock cleanup on exceptions, and cancellation handling.
@cached bugs:
lock=False, misses were never incremented and hits were double-counted. Now they are counted correctly.cachebox__ignore=True and lock was off, the function was not awaited and a coroutine object was returned. Now it is properly awaited.BaseException) now go through the same cleanup path (previously only Exceptions was caught).In Frozen class, the check for the underlying cache no longer relies on assert (so it still works with -O flag).
Removed an unreachable branch in make_key function.
Full Changelog: https://github.com/awolverp/cachebox/compare/v6.2.1...v6.2.2
This is a patch release that fully migrates the crate to stable Rust — no more nightly-only features are used.
This is a patch release that fully migrates the crate to stable Rust — no more nightly-only features are used.
cachebox no longer relies on any unstable Rust features.6.2.0 could not be built with stable Rust (error[E0554]: '#![feature]' may not be used on the stable release channel)This release introduces a new method and improves the atomicity of an existing one, along with a bug fix.
This release introduces a new method and improves the atomicity of an existing one, along with a bug fix.
setdefault_with method to cache classes for more flexible atomic operations.setdefault is now fully atomic, improving thread-safety and reliability.Security fixes and internal soundness improvements from PyO3.
This release updates the core dependency to PyO3 0.29.0. This is a patch release with dependency and compatibility updates.
This release includes a critical fix for a bug where exceptions raised by functions wrapped with @cached ( with enabled lock ) could get permanently s
This release includes a critical fix for a bug where exceptions raised by functions wrapped with @cached ( with enabled lock ) could get permanently stuck in the cache. Once an exception was cached, subsequent calls would always re-raise it immediately without re-executing the function or allowing the cache to clear properly.
A critical bug has been fixed, and a new feature has been added. Now you can disable or use a custom lock for *cache stampede prevention* in @cached d
A critical bug has been fixed, and a new feature has been added. Now you can disable or use a custom lock for cache stampede prevention in @cached decorator.
lock parameter to the @cached decorator, providing more control on cache stampede prevention. Also fixes #54.Added postprocess parameter to the @cached decorator, providing much more flexible control over cached results (replaces the deprecated copy_level).
The library has been completely optimized and rewritten for maximum performance and stability. All core algorithms have been reviewed and improved, multiple long-standing bugs have been fixed, and several requested features have been added.
postprocess parameter to the @cached decorator, providing much more flexible control over cached results (replaces the deprecated copy_level).getsizeof parameter to cache classes. This callable allows implementing weighted caching based on memory footprint, object size, or any custom logic.TTLCache and VTTLCache via the new sweep_interval parameter. When set, a background thread automatically cleans up expired items (#46).current_size()remaining_size()contains()get_cached_cache()get_cached_cache_info()get_cached_callback()clear_cached_cache()FIFOCache and TTLCache.@cached decorator now uses LRUCache by default, instead of FIFOCache.copy_level parameter in @cached has been deprecated and no longer has any effect.TTLCache.ttl has been renamed to TTLCache.global_ttl to avoid confusion with per-item TTL.cachedmethod decorator has been completely removed (deprecated since v5.1.0).maxmemory parameter has been removed due to severe performance regression. Use getsizeof for weighted caching instead.__getstate__ / __setstate__). Pickled caches from v5 may not be compatible with v6.Read Migration Guide
Improve wording and formatting in README.md by @privatwolke in https://github.com/awolverp/cachebox/pull/44
cached function by @liblaf in https://github.com/awolverp/cachebox/pull/45Full Changelog: https://github.com/awolverp/cachebox/compare/v5.2.2...v5.2.3
Nothing published for this version
In the latest update we had ( *v5.2.0* ), adding the mimalloc allocator for some platforms made it impossible to use cachebox on musl Linux systems. T
In the latest update we had ( v5.2.0 ), adding the mimalloc allocator for some platforms made it impossible to use cachebox on musl Linux systems. Thanks to @mpihelgas for reporting this issue and to @chirizxc for fixing this bug.
local_dynamic_tls mimalloc feature by @chirizxc in https://github.com/awolverp/cachebox/pull/42Full Changelog: https://github.com/awolverp/cachebox/compare/v5.2.0...v5.2.1
Starting now, cachebox uses mimalloc as the default allocator for some targets ( thanks to @chirizxc, https://github.com/awolverp/cachebox/pull/37)
mimalloc as the default allocator for some targets ( thanks to @chirizxc, https://github.com/awolverp/cachebox/pull/37)maxmemory parameter. ( thanks to @stalkerg, https://github.com/awolverp/cachebox/pull/39)Full Changelog: https://github.com/awolverp/cachebox/compare/v5.1.0...v5.2.0
Now the cached function can accept a function as cache, allowing it to replace cachedmethod function. Also this can give you more control.
cached function can accept a function as cache, allowing it to replace cachedmethod function. Also this can give you more control.Rewrite build workflow to support Python 3.13t, 3.14 and 3.14t on all platforms (#34; thanks to @chirizxc)
Full Changelog: https://github.com/awolverp/cachebox/compare/v5.0.3...v5.0.4
Use parking_lot::Mutex instead of duplicating its code ( by @chirizxc )
Support python 3.14 by @chirizxc in https://github.com/awolverp/cachebox/pull/27
Full Changelog: https://github.com/awolverp/cachebox/compare/v5.0.1...v5.0.2
### Changed - The issue #25 fixed - Type-hint improved - FIFOCache.get docstring fixed ### Thanks to - @Techcable for the issue
FIFOCache.get docstring fixedA new method named random_key added to RRCache.
Notable changes are listed:
random_key added to RRCache.expire added to TTLCache.VTTLCache: expire, items_with_expire.TTLCache now supports timedelta as ttl.VTTLCache now supports timedelta and datetime as ttl.copy added to all caches.__eq__ operations will not be ignored:class A:
def __hash__(self):
return 1
def __eq__(self, other):
raise NotImplementedError("not implemeneted")
cache = cachebox.FIFOCache(0, {A(): 10})
cache[A()]
# Traceback (most recent call last):
# File "script.py", line 11, in <module>
# cache[A()]
# ~~~~~^^^^^
# File "script.py", line 7, in __eq__
# raise NotImplementedError("not implemeneted")
# NotImplementedError: not implemeneted
__repr__ methods refactored:cachebox.LRUCache(100, {i:i for i in range(100)})
# cachebox._cachebox.LRUCache[100/100]({0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 17: 17, 18: 18, 19: 19, 20: 20, 21: 21, 22: 22, 23: 23, 24: 24, 25: 25, 26: 26, 27: 27, 28: 28, 29: 29, 30: 30, 31: 31, 32: 32, 33: 33, 34: 34, 35: 35, 36: 36, 37: 37, 38: 38, 39: 39, 40: 40, 41: 41, 42: 42, 43: 43, 44: 44, 45: 45, 46: 46, 47: 47, 48: 48, 49: 49, 50: 50, ... 49 more ...})
CacheInfo.cachememory renamed to CacheInfo.memory.n parameter of the LRUCache.least_recently_used method has been removed.For more info, see changelog
The cached and cachedmethods decorators cached the exceptions regardless of the number of waiters. This issue has now been resolved.
Fix for clear_cache in decorators
Fix for clear_cache in decorators
In previous version, clear_cache, does not clear the exceptions dictionary.
A small fix for version v4.5.0.
A small fix for version v4.5.0.
In previous version, the cached and cachedmethod functions caught a KeyError from the callback function, which led to the cached function being called again.
Now cachebox uses threading.Lock for sync functions, and asyncio.Lock for async functions to avoid `cache stampede`. These changes fix #15 and #20 iss
cached and cachedmethod improvedNow cachebox uses threading.Lock for sync functions, and asyncio.Lock for async functions to avoid cache stampede. These changes fix #15 and #20 issues.
No important changes were made to the library.
No important changes were made to the library.
Pyo3 dependency updated and Box layout removed from Rust code.
No changes were made to the library. Only dependencies updated, such as PyO3 that has a soundness fix.
No changes were made to the library. Only dependencies updated, such as PyO3 that has a soundness fix.
The always_copy parameter marked as deprecated.
copy_level parameter added to cachedmethod and cached.always_copy parameter marked as deprecated.cached and cachedmethod structures changed due to some issues.typing_extensions dependency removed.info parameter removed from cachedmethod and cached.Nothing published for this version
New dependency is added: typing_extensions. We used this library to use ParamSpec that makes cachebox type-hint better, and easier than ever for you.
New dependency is added: typing_extensions.
We used this library to use ParamSpec that makes cachebox type-hint better, and easier than ever for you.
the behaviour of the iteratores changed. Previously, iterators used capacity and length of the cache to know "is cache have changes?". But now, each cache has a number called "state" that increments with each change; iterators now uses this "state" number.
Free-threading is supported now
__str__ changed to __repr__Add always_copy parameter to cached and cachedmethod decorators; This is useful when function returns mutable results, such as dict, list, or set, ...
always_copy parameter to cached and cachedmethod decorators; This is useful when function returns mutable results, such as dict, list, or set, ....Release v4.2.2 was missing some .whl files for linux. Thanks @ecarrara for the fix, Thanks @ksquarekumar for the report.
Release v4.2.2 was missing some .whl files for linux. Thanks @ecarrara for the fix, Thanks @ksquarekumar for the report.
In this release we support Python `3.13`
In this release we support Python 3.13
TTLCache.__str__ fixedFix BaseCacheImpl.__class_getitem__
BaseCacheImpl.__class_getitem__cache = cachebox.Cache[int, int](0) # Before this release, you will get error but now is OK
cached and cachedmethod type-hintNew function is_cached is added.
is_cached is added.callback is added to cached and cachedmethod: now you can set a callback for cached functions.Nothing published for this version
https://github.com/awolverp/cachebox/issues/11 bug fixed
Nothing published for this version
cached type-hint is better now.
cached type-hint is better now.cached documentation.Nothing published for this version
utils.items_in_order function is deprecated and no longer available.
The Big Update ...
FrozenBaseCacheImpl as subclass was cause NotImplementedError, but now fixed.make_*_key functions error fixedAll of caches improved and their perfomance improved a lot.
All of caches' algorthims changed:
Cache performance improved about 5%.FIFOCache performance improved about 20%.LFUCache performance improved about 46%.TTLCache performance improved about 30%.VTTLCache performance improved about 20%.LRUCache performance improved about 40%.All of .items() and .keys() and .values() methods are now ordered.
.insert() method changed: If the cache did have this key present, the value is updated, and the old value is returned.
utils.items_in_order function is deprecated and no longer available.items_in_order function added - helps you to iterate caches items in order
items_in_order function added - helps you to iterate caches items in orderLRUCache alghoritm changed and optimized (4x faster)ttl parameter of VTTLCache.insert now has a default value (None).### Fixed - Change comparing alghoritm - Fix #5
Added new parameter n to .first() method.
FIFOCache:
n to .first() method.LFUCache:
.peek() method is added.n to .least_frequently_used() method is added.LRUCache:
.peek() method is added.n to .least_recently_used() method is added.TTLCache:
.first() and .last() methods are added.Nothing published for this version
pyproject.toml classifiers changed and fixed
version_info variablecached and cachedmethod will use FIFOCache on default (previously it used Cache).
cached and cachedmethod will use FIFOCache on default (previously it used Cache).Add a little document to Rust code
pickleAll of caches were rewritten and optimized; behavior of iterators changed.
All of caches were rewritten and optimized; behavior of iterators changed.
See https://github.com/awolverp/cachebox/pull/2 for more info.
### Fixed - Document fixed ### Internal - Dependecies updated
Reduce memory usages and allocations
VTTLCache.__delitem__VTTLCache.__delitem__ method for more speed.hashbrown instead of standard hashmap.unsafe blocks in safe situations to optimize performanceThe behavior of the __repr__ function has been changed and improved.
__repr__ function has been changed and improved.RRCache performance.pyo3 updated and features changed.fastrand instead of rand.Fix RuntimeError when you passing a cache implemetation to its own methods.
RuntimeError when you passing a cache implemetation to its own methods.Enjoy 😉 ...
Remove deprecated methods (getmaxsize, getttl, and delete)
VTTLCache)getmaxsize, getttl, and delete)New decorator cachedmethod for class methods.
cachedmethod for class methods.cached accept None as cache.Now cachebox.Cache is as fast as python dictionary ...
Now cachebox.Cache is as fast as python dictionary ...
strip value changed.AHashMap instead of standard HashMap; that's very faster..delete() methods are deprecated; use del cache[key] instead.
In this release, I rewritten all implemetations, documentation, and stub-file.
.drain(n) method: According to cache algorithm, deletes and returns n items from cache..shrink_to_fit() method: Shrinks the capacity of the cache as much as possible.MRUCache removed.__new__ methods changed; Now you can insert items to caches when creating those.TTLCacheNoDefault name changed to VTTLCache.__iter__, keys, values and items methods now are iterable.LFUCache sorting algorithm changed to improve speed.__eq__ and __ne__ methods changed.cached decorator parameter clear_reuse default value from True changed to False..delete() methods are deprecated; use del cache[key] instead..getmaxsize() methods are deprecated; use .maxsize property instead.TTLCache.getttl() method is deprecated; use .ttl property instead.make_typed_key function bug fixed.codegen-units value changed.strip value changed to reduce binary file size.typing_extensionsNothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →