CacheToolsUtils 8.4__tar.gz → 8.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/CacheToolsUtils.egg-info/PKG-INFO +10 -5
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/CacheToolsUtils.egg-info/requires.txt +1 -0
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/CacheToolsUtils.py +18 -18
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/PKG-INFO +10 -5
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/README.md +8 -4
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/pyproject.toml +2 -2
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/CacheToolsUtils.egg-info/SOURCES.txt +0 -0
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/CacheToolsUtils.egg-info/dependency_links.txt +0 -0
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/CacheToolsUtils.egg-info/top_level.txt +0 -0
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/LICENSE +0 -0
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/MANIFEST.in +0 -0
- {CacheToolsUtils-8.4 → cachetoolsutils-8.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: CacheToolsUtils
|
|
3
|
-
Version: 8.
|
|
3
|
+
Version: 8.6
|
|
4
4
|
Summary: Cachetools Utilities
|
|
5
5
|
Author-email: Fabien Coelho <cachetools.utils@coelho.net>
|
|
6
6
|
License: CC0
|
|
@@ -22,6 +22,7 @@ Requires-Dist: mypy; extra == "dev"
|
|
|
22
22
|
Requires-Dist: pyright; extra == "dev"
|
|
23
23
|
Requires-Dist: black; extra == "dev"
|
|
24
24
|
Requires-Dist: flake8; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff; extra == "dev"
|
|
25
26
|
Requires-Dist: pytest; extra == "dev"
|
|
26
27
|
Requires-Dist: coverage; extra == "dev"
|
|
27
28
|
Requires-Dist: pymarkdownlnt; extra == "dev"
|
|
@@ -90,6 +91,14 @@ with `cachetools`.
|
|
|
90
91
|
function result is in cache, and to delete such an entry.
|
|
91
92
|
- `cacheFunctions` and `cacheMethods`: add caching to functions or methods.
|
|
92
93
|
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
This code is [Public Domain](https://creativecommons.org/publicdomain/zero/1.0/).
|
|
97
|
+
|
|
98
|
+
All software has bug, this is software, hence… Beware that you may lose your
|
|
99
|
+
hairs or your friends because of it. If you like it, feel free to send a
|
|
100
|
+
postcard to the author.
|
|
101
|
+
|
|
93
102
|
## More
|
|
94
103
|
|
|
95
104
|
See the
|
|
@@ -98,7 +107,3 @@ See the
|
|
|
98
107
|
[issues](https://github.com/zx80/cachetools-utils/issues) on GitHub.
|
|
99
108
|
|
|
100
109
|
See [packages](https://pypi.org/project/CacheToolsUtils/) on PyPI.
|
|
101
|
-
|
|
102
|
-
## License
|
|
103
|
-
|
|
104
|
-
This code is public domain.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CacheTools Utilities. This code is public domain.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Any, Callable, MutableMapping
|
|
5
|
+
from typing import Any, Callable, MutableMapping
|
|
6
6
|
import abc
|
|
7
7
|
|
|
8
8
|
import cachetools
|
|
@@ -25,7 +25,7 @@ _NO_DEFAULT = object()
|
|
|
25
25
|
class _MutMapMix:
|
|
26
26
|
"""Convenient MutableMapping Mixin, forward to _cache."""
|
|
27
27
|
|
|
28
|
-
_cache:
|
|
28
|
+
_cache: MutableMapping
|
|
29
29
|
|
|
30
30
|
def __contains__(self, key):
|
|
31
31
|
return self._cache.__contains__(key)
|
|
@@ -102,7 +102,7 @@ class _RedisMix: # pragma: no cover
|
|
|
102
102
|
# CACHETOOLS EXTENSIONS
|
|
103
103
|
#
|
|
104
104
|
|
|
105
|
-
class DebugCache:
|
|
105
|
+
class DebugCache(MutableMapping):
|
|
106
106
|
"""Debug class.
|
|
107
107
|
|
|
108
108
|
:param cache: actual cache
|
|
@@ -110,7 +110,7 @@ class DebugCache:
|
|
|
110
110
|
:param name: name of instance for output
|
|
111
111
|
"""
|
|
112
112
|
|
|
113
|
-
def __init__(self, cache:
|
|
113
|
+
def __init__(self, cache: MutableMapping, log: logging.Logger, name="cache"):
|
|
114
114
|
self._cache = cache
|
|
115
115
|
self._log = log
|
|
116
116
|
self._name = name
|
|
@@ -152,7 +152,7 @@ class DebugCache:
|
|
|
152
152
|
return self._cache.reset() # type: ignore
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
class DictCache(_MutMapMix):
|
|
155
|
+
class DictCache(_MutMapMix, MutableMapping):
|
|
156
156
|
"""Cache class based on dict."""
|
|
157
157
|
|
|
158
158
|
def __init__(self):
|
|
@@ -162,7 +162,7 @@ class DictCache(_MutMapMix):
|
|
|
162
162
|
self._cache.clear()
|
|
163
163
|
|
|
164
164
|
|
|
165
|
-
class LockedCache(_MutMapMix, _StatsMix, _RedisMix,
|
|
165
|
+
class LockedCache(_MutMapMix, _StatsMix, _RedisMix, MutableMapping):
|
|
166
166
|
"""Cache class with a lock.
|
|
167
167
|
|
|
168
168
|
:param cache: actual cache.
|
|
@@ -178,7 +178,7 @@ class LockedCache(_MutMapMix, _StatsMix, _RedisMix, MutMap):
|
|
|
178
178
|
cache = ctu.LockedCache(ct.LFUCache(), threading.RLock())
|
|
179
179
|
"""
|
|
180
180
|
|
|
181
|
-
def __init__(self, cache:
|
|
181
|
+
def __init__(self, cache: MutableMapping, lock):
|
|
182
182
|
self._cache = cache
|
|
183
183
|
self._lock = lock
|
|
184
184
|
|
|
@@ -199,14 +199,14 @@ class LockedCache(_MutMapMix, _StatsMix, _RedisMix, MutMap):
|
|
|
199
199
|
return self._cache.__delitem__(key)
|
|
200
200
|
|
|
201
201
|
|
|
202
|
-
class PrefixedCache(_KeyMutMapMix, _StatsMix,
|
|
202
|
+
class PrefixedCache(_KeyMutMapMix, _StatsMix, MutableMapping):
|
|
203
203
|
"""Cache class to add a key prefix.
|
|
204
204
|
|
|
205
205
|
:param cache: actual cache.
|
|
206
206
|
:param prefix: prefix to prepend to keys.
|
|
207
207
|
"""
|
|
208
208
|
|
|
209
|
-
def __init__(self, cache:
|
|
209
|
+
def __init__(self, cache: MutableMapping, prefix: str|bytes = ""):
|
|
210
210
|
self._prefix = prefix
|
|
211
211
|
self._cache = cache
|
|
212
212
|
# dynamic cast
|
|
@@ -220,7 +220,7 @@ class PrefixedCache(_KeyMutMapMix, _StatsMix, MutMap):
|
|
|
220
220
|
return self._prefix + self._cast(key) # type: ignore
|
|
221
221
|
|
|
222
222
|
|
|
223
|
-
class StatsCache(_MutMapMix,
|
|
223
|
+
class StatsCache(_MutMapMix, MutableMapping):
|
|
224
224
|
"""Cache class to keep stats.
|
|
225
225
|
|
|
226
226
|
:param cache: actual cache.
|
|
@@ -237,7 +237,7 @@ class StatsCache(_MutMapMix, MutMap):
|
|
|
237
237
|
However, this only works for its own classes.
|
|
238
238
|
"""
|
|
239
239
|
|
|
240
|
-
def __init__(self, cache:
|
|
240
|
+
def __init__(self, cache: MutableMapping):
|
|
241
241
|
self._cache = cache
|
|
242
242
|
self.reset()
|
|
243
243
|
|
|
@@ -267,7 +267,7 @@ class StatsCache(_MutMapMix, MutMap):
|
|
|
267
267
|
return self._cache.clear()
|
|
268
268
|
|
|
269
269
|
|
|
270
|
-
class TwoLevelCache(_MutMapMix,
|
|
270
|
+
class TwoLevelCache(_MutMapMix, MutableMapping):
|
|
271
271
|
"""Two-Level Cache class for CacheTools.
|
|
272
272
|
|
|
273
273
|
:param cache: first (smaller, shorter TTL) cache
|
|
@@ -275,7 +275,7 @@ class TwoLevelCache(_MutMapMix, MutMap):
|
|
|
275
275
|
:param resilient: whether to ignore cache2 failures
|
|
276
276
|
"""
|
|
277
277
|
|
|
278
|
-
def __init__(self, cache:
|
|
278
|
+
def __init__(self, cache: MutableMapping, cache2: MutableMapping, resilient=False):
|
|
279
279
|
self._resilient = resilient
|
|
280
280
|
self._cache = cache
|
|
281
281
|
self._cache2 = cache2
|
|
@@ -370,10 +370,10 @@ def cached(cache, *args, **kwargs):
|
|
|
370
370
|
|
|
371
371
|
|
|
372
372
|
# short generator type name
|
|
373
|
-
MapGen = Callable[[
|
|
373
|
+
MapGen = Callable[[MutableMapping, str], MutableMapping]
|
|
374
374
|
|
|
375
375
|
|
|
376
|
-
def cacheMethods(cache:
|
|
376
|
+
def cacheMethods(cache: MutableMapping, obj: Any, gen: MapGen = PrefixedCache, **funs):
|
|
377
377
|
"""Cache some object methods.
|
|
378
378
|
|
|
379
379
|
:param cache: cache to use.
|
|
@@ -394,7 +394,7 @@ def cacheMethods(cache: MutMap, obj: Any, gen: MapGen = PrefixedCache, **funs):
|
|
|
394
394
|
|
|
395
395
|
|
|
396
396
|
def cacheFunctions(
|
|
397
|
-
cache:
|
|
397
|
+
cache: MutableMapping, globs: MutableMapping[str, Any], gen: MapGen = PrefixedCache, **funs
|
|
398
398
|
):
|
|
399
399
|
"""Cache some global functions, with a prefix.
|
|
400
400
|
|
|
@@ -445,7 +445,7 @@ class JsonSerde:
|
|
|
445
445
|
raise Exception("Unknown serialization format")
|
|
446
446
|
|
|
447
447
|
|
|
448
|
-
class MemCached(_KeyMutMapMix,
|
|
448
|
+
class MemCached(_KeyMutMapMix, MutableMapping):
|
|
449
449
|
"""MemCached-compatible wrapper class for cachetools with key encoding.
|
|
450
450
|
|
|
451
451
|
:param cache: actual memcached cache.
|
|
@@ -528,7 +528,7 @@ class StatsMemCached(MemCached):
|
|
|
528
528
|
#
|
|
529
529
|
|
|
530
530
|
|
|
531
|
-
class RedisCache(
|
|
531
|
+
class RedisCache(MutableMapping):
|
|
532
532
|
"""Redis TTL-ed wrapper for cachetools (``redis``).
|
|
533
533
|
|
|
534
534
|
:param cache: actual redis cache.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: CacheToolsUtils
|
|
3
|
-
Version: 8.
|
|
3
|
+
Version: 8.6
|
|
4
4
|
Summary: Cachetools Utilities
|
|
5
5
|
Author-email: Fabien Coelho <cachetools.utils@coelho.net>
|
|
6
6
|
License: CC0
|
|
@@ -22,6 +22,7 @@ Requires-Dist: mypy; extra == "dev"
|
|
|
22
22
|
Requires-Dist: pyright; extra == "dev"
|
|
23
23
|
Requires-Dist: black; extra == "dev"
|
|
24
24
|
Requires-Dist: flake8; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff; extra == "dev"
|
|
25
26
|
Requires-Dist: pytest; extra == "dev"
|
|
26
27
|
Requires-Dist: coverage; extra == "dev"
|
|
27
28
|
Requires-Dist: pymarkdownlnt; extra == "dev"
|
|
@@ -90,6 +91,14 @@ with `cachetools`.
|
|
|
90
91
|
function result is in cache, and to delete such an entry.
|
|
91
92
|
- `cacheFunctions` and `cacheMethods`: add caching to functions or methods.
|
|
92
93
|
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
This code is [Public Domain](https://creativecommons.org/publicdomain/zero/1.0/).
|
|
97
|
+
|
|
98
|
+
All software has bug, this is software, hence… Beware that you may lose your
|
|
99
|
+
hairs or your friends because of it. If you like it, feel free to send a
|
|
100
|
+
postcard to the author.
|
|
101
|
+
|
|
93
102
|
## More
|
|
94
103
|
|
|
95
104
|
See the
|
|
@@ -98,7 +107,3 @@ See the
|
|
|
98
107
|
[issues](https://github.com/zx80/cachetools-utils/issues) on GitHub.
|
|
99
108
|
|
|
100
109
|
See [packages](https://pypi.org/project/CacheToolsUtils/) on PyPI.
|
|
101
|
-
|
|
102
|
-
## License
|
|
103
|
-
|
|
104
|
-
This code is public domain.
|
|
@@ -47,6 +47,14 @@ with `cachetools`.
|
|
|
47
47
|
function result is in cache, and to delete such an entry.
|
|
48
48
|
- `cacheFunctions` and `cacheMethods`: add caching to functions or methods.
|
|
49
49
|
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
This code is [Public Domain](https://creativecommons.org/publicdomain/zero/1.0/).
|
|
53
|
+
|
|
54
|
+
All software has bug, this is software, hence… Beware that you may lose your
|
|
55
|
+
hairs or your friends because of it. If you like it, feel free to send a
|
|
56
|
+
postcard to the author.
|
|
57
|
+
|
|
50
58
|
## More
|
|
51
59
|
|
|
52
60
|
See the
|
|
@@ -55,7 +63,3 @@ See the
|
|
|
55
63
|
[issues](https://github.com/zx80/cachetools-utils/issues) on GitHub.
|
|
56
64
|
|
|
57
65
|
See [packages](https://pypi.org/project/CacheToolsUtils/) on PyPI.
|
|
58
|
-
|
|
59
|
-
## License
|
|
60
|
-
|
|
61
|
-
This code is public domain.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "CacheToolsUtils"
|
|
7
|
-
version = "8.
|
|
7
|
+
version = "8.6"
|
|
8
8
|
authors = [ { name = "Fabien Coelho", email = "cachetools.utils@coelho.net" } ]
|
|
9
9
|
description = "Cachetools Utilities"
|
|
10
10
|
readme = "README.md"
|
|
@@ -30,7 +30,7 @@ package = "https://pypi.org/project/CacheToolsUtils/"
|
|
|
30
30
|
py-modules = [ "CacheToolsUtils" ]
|
|
31
31
|
|
|
32
32
|
[project.optional-dependencies]
|
|
33
|
-
dev = [ "mypy", "pyright", "black", "flake8", "pytest", "coverage", "pymarkdownlnt", "types-redis", "types-cachetools" ]
|
|
33
|
+
dev = [ "mypy", "pyright", "black", "flake8", "ruff", "pytest", "coverage", "pymarkdownlnt", "types-redis", "types-cachetools" ]
|
|
34
34
|
doc = [ "sphinx", "sphinx_rtd_theme", "sphinx-autoapi", "sphinx-lint", "myst_parser" ]
|
|
35
35
|
tests = [ "pymemcache", "redis" ]
|
|
36
36
|
pub = [ "build", "wheel", "twine" ]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|