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.typedmethodkey
decorator. - Deprecate
MRUCache
class. - Deprecate
@func.mru_cache
decorator. - 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@cached
decorator.
- 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
src
directory tosys.path
for Sphinx autodoc. - Modernize
func
wrappers.
- 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
,rr
andttl
submodules have been deleted. Therefore, statements likefrom cachetools.ttl import TTLCache
will no longer work. Use
from cachetools import TTLCache
instead.
Pass
self
to@cachedmethod
key function (breaking change).The
key
function passed to the@cachedmethod
decorator 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
@cachedmethod
decorator.Change exact time of expiration in
TTLCache
(breaking change).TTLCache
items 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 aTTLCache
withttl=0
can 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
TTLCache
withdatetime
. - 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_function
withcachetools.func
decorators (Python 3.8 compatibility). - Support
cache_parameters()
withcachetools.func
decorators (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.monotonic
as default timer if available. - Improve documentation regarding thread safety.
- Officially support Python 3.7.
- Drop Python 3.3 support (breaking change).
- Remove
missing
cache constructor parameter (breaking change). - Remove
self
from@cachedmethod
key arguments (breaking change). - Add support for
maxsize=None
incachetools.func
decorators.
- Deprecate
missing
cache constructor parameter. - Handle overridden
getsizeof()
method in subclasses. - Fix Python 2.7
RRCache
pickling 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
maxsize
inCache.__repr__()
.
- Reimplement
LRUCache
andTTLCache
usingcollections.OrderedDict
. Note that this will break pickle compatibility with previous versions. - Fix
TTLCache
not calling__missing__()
of derived classes. - Handle
ValueError
inCache.__missing__()
for consistency with caching decorators. - Improve how
TTLCache
handles expired items. - Use
Counter.most_common()
forLFUCache.popitem()
.
- Refactor
Cache
base class. Note that this will break pickle compatibility with previous versions. - Clean up
LRUCache
andTTLCache
implementations.
- Refactor
LRUCache
andTTLCache
implementations. 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
LRUCache
andTTLCache
instances.
- Improve key functions.
- Improve documentation.
- Improve unit test coverage.
- Add
@cached
function decorator. - Add
hashkey
andtypedkey
functions. - Add key and lock arguments to
@cachedmethod
. - Set
__wrapped__
attributes for Python versions < 3.2. - Move
functools
compatible decorators tocachetools.func
. - Deprecate
@cachedmethod
typed argument. - Deprecate cache attribute for
@cachedmethod
wrappers. - 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.getsizeof
andCache.missing
default implementation.
- Code cleanup for improved PEP 8 conformance.
- Add documentation and unit tests for using
@cachedmethod
with generic mutable mappings. - Improve documentation.
- Provide
RRCache.choice
property. - Improve documentation.
- Use a
NestedTimer
forTTLCache
.
- Deprecate
Cache.getsize()
.
- Ignore
ValueError
raised 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
RRCache
constructor. - Refactor
LFUCache
,LRUCache
andTTLCache
. - Use custom
NullContext
implementation for unsynchronized function decorators.
- Raise
TTLCache.ExpiredError
for expiredTTLCache
items. - Support unsynchronized function decorators.
- Allow
@cachedmethod.cache()
to return None
- No formatting of
KeyError
arguments. - Update
README.rst
.
- Do not delete expired items in TTLCache.__getitem__().
- Add
@ttl_cache
function decorator. - Fix public
getsizeof()
usage.
- Add
TTLCache
. - Add
Cache
base class. - Remove
@cachedmethod
lock parameter.
- Add proper locking for
cache_clear()
andcache_info()
. - Report size in
cache_info()
.
- Remove
@cache
decorator. - Add
size
,getsizeof
members. - Add
@cachedmethod
decorator.
- Add
@cache
decorator. - Update documentation.
- Initial release.