- Add support for Python 3.14.
- Improve documentation.
- Update CI environment.
- Improve general
RRCacheperformance by storing cache keys in an additional sequence container. Note that this will increase memory consumption. - Add more unit tests.
- Improve
LFUCacheinsertion performance by switching to an implementation based on the cacheing library. - Update CI environment.
- Require Python 3.9 or later (breaking change).
- Remove
MRUCacheand the@func.mru_cachedecorator (breaking change). - Add an optional
conditionparameter to the@cachedand@cachedmethoddecorators, which, when used with athreading.Conditioninstance, should improve cache stampede issues in massively parallel environments. Note that this will inflict some performance penalty, and therefore has to be enabled explicitly. - Convert the
cachetools.funcdecorators to use athreading.Conditioninstance to deal with cache stampede issues. Note that this may result in a noticable performance degradation, depending on your actual use case. - Deprecate support for
cache(self)returningNoneto suppress caching with the@cachedmethoddecorator. - Improve documentation.
- Update CI environment.
- Reduce number of
@cachedlock/unlock operations. - Improve documentation.
- Update CI environment.
- Add documentation regarding caching of exceptions.
- Officially support Python 3.13.
- Update CI environment.
TTLCache.expire()returns iterable of expired(key, value)pairs.TLRUCache.expire()returns iterable of expired(key, value)pairs.- Documentation improvements.
- Update CI environment.
- Add the
keys.typedmethodkeydecorator. - Deprecate
MRUCacheclass. - Deprecate
@func.mru_cachedecorator. - Update CI environment.
- Documentation improvements.
- Update CI environment.
- Add support for Python 3.12.
- Various documentation improvements.
- Depend on Python >= 3.7.
- Add
cache_info()function to@cacheddecorator.
- Add support for Python 3.11.
- Correct version information in RTD documentation.
badges/shields: Change to GitHub workflow badge routes.
- Add
cachetools.keys.methodkey(). - Add
cache_clear()function to decorators. - Add
srcdirectory tosys.pathfor Sphinx autodoc. - Modernize
funcwrappers.
- Add cache decorator parameters as wrapper function attributes.
Require Python 3.7 or later (breaking change).
Remove deprecated submodules (breaking change).
The
cache,fifo,lfu,lru,mru,rrandttlsubmodules have been deleted. Therefore, statements likefrom cachetools.ttl import TTLCachewill no longer work. Use
from cachetools import TTLCacheinstead.
Pass
selfto@cachedmethodkey function (breaking change).The
keyfunction passed to the@cachedmethoddecorator is now called askey(self, *args, **kwargs).The default key function has been changed to ignore its first argument, so this should only affect applications using custom key functions with the
@cachedmethoddecorator.Change exact time of expiration in
TTLCache(breaking change).TTLCacheitems now get expired if their expiration time is less than or equal totimer(). For applications using the defaulttimer(), this should be barely noticeable, but it may affect the use of custom timers with larger tick intervals. Note that this also implies that aTTLCachewithttl=0can no longer hold any items, since they will expire immediately.Change
Cache.__repr__()format (breaking change).String representations of cache instances now use a more compact and efficient format, e.g.
LRUCache({1: 1, 2: 2}, maxsize=10, currsize=2)Add TLRU cache implementation.
Documentation improvements.
- Add submodule shims for backward compatibility.
- Add documentation and tests for using
TTLCachewithdatetime. - Link to typeshed typing stubs.
- Flatten package file hierarchy.
- Update build environment.
- Remove Python 2 remnants.
- Format code with Black.
- Handle
__missing__()not storing cache items. - Clean up
__missing__()example.
- Add FIFO cache implementation.
- Add MRU cache implementation.
- Improve behavior of decorators in case of race conditions.
- Improve documentation regarding mutability of caches values and use of key functions with decorators.
- Officially support Python 3.9.
- Improve
popitem()exception context handling. - Replace
float('inf')withmath.inf. - Improve "envkey" documentation example.
- Support
user_functionwithcachetools.funcdecorators (Python 3.8 compatibility). - Support
cache_parameters()withcachetools.funcdecorators (Python 3.9 compatibility).
- Require Python 3.5 or later.
- Document how to use shared caches with
@cachedmethod. - Fix pickling/unpickling of cache keys
- Fix Python 3.8 compatibility issue.
- Use
time.monotonicas default timer if available. - Improve documentation regarding thread safety.
- Officially support Python 3.7.
- Drop Python 3.3 support (breaking change).
- Remove
missingcache constructor parameter (breaking change). - Remove
selffrom@cachedmethodkey arguments (breaking change). - Add support for
maxsize=Noneincachetools.funcdecorators.
- Deprecate
missingcache constructor parameter. - Handle overridden
getsizeof()method in subclasses. - Fix Python 2.7
RRCachepickling issues. - Various documentation improvements.
- Officially support Python 3.6.
- Move documentation to RTD.
- Documentation: Update import paths for key functions (courtesy of slavkoja).
- Drop Python 3.2 support (breaking change).
- Drop support for deprecated features (breaking change).
- Move key functions to separate package (breaking change).
- Accept non-integer
maxsizeinCache.__repr__().
- Reimplement
LRUCacheandTTLCacheusingcollections.OrderedDict. Note that this will break pickle compatibility with previous versions. - Fix
TTLCachenot calling__missing__()of derived classes. - Handle
ValueErrorinCache.__missing__()for consistency with caching decorators. - Improve how
TTLCachehandles expired items. - Use
Counter.most_common()forLFUCache.popitem().
- Refactor
Cachebase class. Note that this will break pickle compatibility with previous versions. - Clean up
LRUCacheandTTLCacheimplementations.
- Refactor
LRUCacheandTTLCacheimplementations. Note that this will break pickle compatibility with previous versions. - Document pending removal of deprecated features.
- Minor documentation improvements.
- Fix pickle tests.
- Fix pickling of large
LRUCacheandTTLCacheinstances.
- Improve key functions.
- Improve documentation.
- Improve unit test coverage.
- Add
@cachedfunction decorator. - Add
hashkeyandtypedkeyfunctions. - Add key and lock arguments to
@cachedmethod. - Set
__wrapped__attributes for Python versions < 3.2. - Move
functoolscompatible decorators tocachetools.func. - Deprecate
@cachedmethodtyped argument. - Deprecate cache attribute for
@cachedmethodwrappers. - Deprecate getsizeof and lock arguments for cachetools.func decorator.
- Clear cache statistics when calling
clear_cache().
- Allow simple cache instances to be pickled.
- Refactor
Cache.getsizeofandCache.missingdefault implementation.
- Code cleanup for improved PEP 8 conformance.
- Add documentation and unit tests for using
@cachedmethodwith generic mutable mappings. - Improve documentation.
- Provide
RRCache.choiceproperty. - Improve documentation.
- Use a
NestedTimerforTTLCache.
- Deprecate
Cache.getsize().
- Ignore
ValueErrorraised on cache insertion in decorators. - Add
Cache.getsize(). - Add
Cache.__missing__(). - Feature freeze for v1.0.
- Fix MANIFEST.in.
- Deprecate
TTLCache.ExpiredError. - Add choice argument to
RRCacheconstructor. - Refactor
LFUCache,LRUCacheandTTLCache. - Use custom
NullContextimplementation for unsynchronized function decorators.
- Raise
TTLCache.ExpiredErrorfor expiredTTLCacheitems. - Support unsynchronized function decorators.
- Allow
@cachedmethod.cache()to return None
- No formatting of
KeyErrorarguments. - Update
README.rst.
- Do not delete expired items in TTLCache.__getitem__().
- Add
@ttl_cachefunction decorator. - Fix public
getsizeof()usage.
- Add
TTLCache. - Add
Cachebase class. - Remove
@cachedmethodlock parameter.
- Add proper locking for
cache_clear()andcache_info(). - Report size in
cache_info().
- Remove
@cachedecorator. - Add
size,getsizeofmembers. - Add
@cachedmethoddecorator.
- Add
@cachedecorator. - Update documentation.
- Initial release.