Metadata-Version: 2.1
Name: CacheToolsUtils
Version: 8.4
Summary: Cachetools Utilities
Author-email: Fabien Coelho <cachetools.utils@coelho.net>
License: CC0
Project-URL: repository, https://github.com/zx80/cachetools-utils
Project-URL: documentation, https://zx80.github.io/cachetools-utils/
Project-URL: issues, https://github.com/zx80/cachetools-utils/issues
Project-URL: package, https://pypi.org/project/CacheToolsUtils/
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cachetools
Provides-Extra: dev
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: pyright ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: coverage ; extra == 'dev'
Requires-Dist: pymarkdownlnt ; extra == 'dev'
Requires-Dist: types-redis ; extra == 'dev'
Requires-Dist: types-cachetools ; extra == 'dev'
Provides-Extra: doc
Requires-Dist: sphinx ; extra == 'doc'
Requires-Dist: sphinx-rtd-theme ; extra == 'doc'
Requires-Dist: sphinx-autoapi ; extra == 'doc'
Requires-Dist: sphinx-lint ; extra == 'doc'
Requires-Dist: myst-parser ; extra == 'doc'
Provides-Extra: pub
Requires-Dist: build ; extra == 'pub'
Requires-Dist: wheel ; extra == 'pub'
Requires-Dist: twine ; extra == 'pub'
Provides-Extra: tests
Requires-Dist: pymemcache ; extra == 'tests'
Requires-Dist: redis ; extra == 'tests'

# CacheToolsUtils

Classes to add key prefix and stats to
[cachetools](https://pypi.org/project/cachetools/) classes and use
[redis](https://redis.io/) and
[memcached](https://memcached.org/) as storage backends,
and other cache-related utils.

![Status](https://github.com/zx80/cachetools-utils/actions/workflows/cachetools-utils.yml/badge.svg?branch=main&style=flat)
![Tests](https://img.shields.io/badge/tests-17%20✓-success)
![Coverage](https://img.shields.io/badge/coverage-100%25-success)
![Issues](https://img.shields.io/github/issues/zx80/cachetools-utils?style=flat)
![Python](https://img.shields.io/badge/python-3-informational)
![Version](https://img.shields.io/pypi/v/CacheToolsUtils)
![Badges](https://img.shields.io/badge/badges-8-informational)
![License](https://img.shields.io/pypi/l/cachetoolsutils?style=flat)

## Module Contents

For our purpose, a cache is a key-value store, aka a dictionary, possibly with
some constraints on keys (type, size) and values (size, serialization).
This module provides new caches, wrappers and other utilities suitable to use
with `cachetools`.

### Cache classes

- `RedisCache` allows to see a Redis server as a python cache
  by wrapping a `redis.Redis` instance.
- `MemCached` does the same for a Memcached server.
  The utility class `JsonSerde` is a convenient JSON serializer-deserializer
  class for Memcached.
- `DictCache` a very simple `dict` cache.

### Other wrappers to extend cache capabilities

- `PrefixedCache`, `PrefixedMemCached` and `PrefixedRedisCache` add a prefix to
  distinguish sources on a shared cache.
- `StatsCache`, `StatsMemCached` and `StatsRedisCache` add a `hits()` method
  to report the cache hit rate.
- `LockedCache` use a (thread) lock to control cache accesses.
- `TwoLevelCache` allows to combine two caches.
- `DebugCache` to trace cache calls using `logging`.

### Cache utilities

- `cached` decorator: a cachetools replacement which allows to test if a
  function result is in cache, and to delete such an entry.
- `cacheFunctions` and `cacheMethods`: add caching to functions or methods.

## More

See the
[documentation](https://zx80.github.io/cachetools-utils/),
[sources](https://github.com/zx80/cachetools-utils) and
[issues](https://github.com/zx80/cachetools-utils/issues) on GitHub.

See [packages](https://pypi.org/project/CacheToolsUtils/) on PyPI.

## License

This code is public domain.
