Changelogs >

Cachetools

PyUp actively tracks 437,546 Python packages for vulnerabilities to keep your Python environments secure.

Scan your dependencies

5.2.0

===================

- Add ``cachetools.keys.methodkey()``.

- Add ``cache_clear()`` function to decorators.

- Add ``src`` directory to ``sys.path`` for Sphinx autodoc.

- Modernize ``func`` wrappers.

5.1.0

===================

- Add cache decorator parameters as wrapper function attributes.

5.0.0

===================

- Require Python 3.7 or later (breaking change).

- Remove deprecated submodules (breaking change).

The ``cache``, ``fifo``, ``lfu``, ``lru``, ``mru``, ``rr`` and
``ttl`` submodules have been deleted. Therefore, statements like

``from 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 as ``key(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 to* ``timer()``. For applications using the default
``timer()``, this should be barely noticable, but it may affect the
use of custom timers with larger tick intervals. Note that this
also implies that a ``TTLCache`` with ``ttl=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.

4.2.4

===================

- Add submodule shims for backward compatibility.

4.2.3

===================

- Add documentation and tests for using ``TTLCache`` with
``datetime``.

- Link to typeshed typing stubs.

- Flatten package file hierarchy.

4.2.2

===================

- Update build environment.

- Remove Python 2 remnants.

- Format code with Black.

4.2.1

===================

- Handle ``__missing__()`` not storing cache items.

- Clean up ``__missing__()`` example.

4.2.0

===================

- 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.

4.1.1

===================

- Improve ``popitem()`` exception context handling.

- Replace ``float('inf')`` with ``math.inf``.

- Improve "envkey" documentation example.

4.1.0

===================

- Support ``user_function`` with ``cachetools.func`` decorators
(Python 3.8 compatibility).

- Support ``cache_parameters()`` with ``cachetools.func`` decorators
(Python 3.9 compatibility).

4.0.0

===================

- Require Python 3.5 or later.

3.1.1

===================

- Document how to use shared caches with ``cachedmethod``.

- Fix pickling/unpickling of cache keys

3.1.0

===================

- Fix Python 3.8 compatibility issue.

- Use ``time.monotonic`` as default timer if available.

- Improve documentation regarding thread safety.

3.0.0

===================

- 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`` in ``cachetools.func`` decorators.

2.1.0

===================

- Deprecate ``missing`` cache constructor parameter.

- Handle overridden ``getsizeof()`` method in subclasses.

- Fix Python 2.7 ``RRCache`` pickling issues.

- Various documentation improvements.

2.0.1

===================

- Officially support Python 3.6.

- Move documentation to RTD.

- Documentation: Update import paths for key functions (courtesy of
slavkoja).

2.0.0

===================

- 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`` in ``Cache.__repr__()``.

1.1.6

===================

- Reimplement ``LRUCache`` and ``TTLCache`` using
``collections.OrderedDict``. Note that this will break pickle
compatibility with previous versions.

- Fix ``TTLCache`` not calling ``__missing__()`` of derived classes.

- Handle ``ValueError`` in ``Cache.__missing__()`` for consistency
with caching decorators.

- Improve how ``TTLCache`` handles expired items.

- Use ``Counter.most_common()`` for ``LFUCache.popitem()``.

1.1.5

===================

- Refactor ``Cache`` base class. Note that this will break pickle
compatibility with previous versions.

- Clean up ``LRUCache`` and ``TTLCache`` implementations.

1.1.4

===================

- Refactor ``LRUCache`` and ``TTLCache`` implementations. Note that
this will break pickle compatibility with previous versions.

- Document pending removal of deprecated features.

- Minor documentation improvements.

1.1.3

===================

- Fix pickle tests.

1.1.2

===================

- Fix pickling of large ``LRUCache`` and ``TTLCache`` instances.

1.1.1

===================

- Improve key functions.

- Improve documentation.

- Improve unit test coverage.

1.1.0

===================

- Add ``cached`` function decorator.

- Add ``hashkey`` and ``typedkey`` fuctions.

- Add `key` and `lock` arguments to ``cachedmethod``.

- Set ``__wrapped__`` attributes for Python versions < 3.2.

- Move ``functools`` compatible decorators to ``cachetools.func``.

- Deprecate ``cachedmethod`` `typed` argument.

- Deprecate `cache` attribute for ``cachedmethod`` wrappers.

- Deprecate `getsizeof` and `lock` arguments for `cachetools.func`
decorator.

1.0.3

===================

- Clear cache statistics when calling ``clear_cache()``.

1.0.2

===================

- Allow simple cache instances to be pickled.

- Refactor ``Cache.getsizeof`` and ``Cache.missing`` default
implementation.

1.0.1

===================

- Code cleanup for improved PEP 8 conformance.

- Add documentation and unit tests for using ``cachedmethod`` with
generic mutable mappings.

- Improve documentation.

1.0.0

===================

- Provide ``RRCache.choice`` property.

- Improve documentation.

0.8.2

===================

- Use a ``NestedTimer`` for ``TTLCache``.

0.8.1

===================

- Deprecate ``Cache.getsize()``.

0.8.0

===================

- Ignore ``ValueError`` raised on cache insertion in decorators.

- Add ``Cache.getsize()``.

- Add ``Cache.__missing__()``.

- Feature freeze for `v1.0`.

0.7.1

===================

- Fix `MANIFEST.in`.

0.7.0

===================

- Deprecate ``TTLCache.ExpiredError``.

- Add `choice` argument to ``RRCache`` constructor.

- Refactor ``LFUCache``, ``LRUCache`` and ``TTLCache``.

- Use custom ``NullContext`` implementation for unsynchronized
function decorators.

0.6.0

===================

- Raise ``TTLCache.ExpiredError`` for expired ``TTLCache`` items.

- Support unsynchronized function decorators.

- Allow ``cachedmethod.cache()`` to return None

0.5.1

===================

- No formatting of ``KeyError`` arguments.

- Update ``README.rst``.

0.5.0

===================

- Do not delete expired items in TTLCache.__getitem__().

- Add ``ttl_cache`` function decorator.

- Fix public ``getsizeof()`` usage.

0.4.0

===================

- Add ``TTLCache``.

- Add ``Cache`` base class.

- Remove ``cachedmethod`` `lock` parameter.

0.3.1

===================

- Add proper locking for ``cache_clear()`` and ``cache_info()``.

- Report `size` in ``cache_info()``.

0.3.0

===================

- Remove ``cache`` decorator.

- Add ``size``, ``getsizeof`` members.

- Add ``cachedmethod`` decorator.

0.2.0

===================

- Add ``cache`` decorator.

- Update documentation.

0.1.0

===================

- Initial release.