CacheToolsUtils 8.4__py3-none-any.whl → 8.6__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CacheToolsUtils
3
- Version: 8.4
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.
@@ -0,0 +1,6 @@
1
+ CacheToolsUtils.py,sha256=kqZNczVcgP_F8oioXBDCqEA5Ux9FovbO_VhlJ67pjiE,18135
2
+ CacheToolsUtils-8.6.dist-info/LICENSE,sha256=y_yFW1bmBAUFCF-ZDyDiq10Ykns_19If5pFnZUzYgeU,33
3
+ CacheToolsUtils-8.6.dist-info/METADATA,sha256=8L90Zezt3-y8LPTq4zHB8TIbjKvV0urezYd5LroZAJ4,4378
4
+ CacheToolsUtils-8.6.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
5
+ CacheToolsUtils-8.6.dist-info/top_level.txt,sha256=qCyE4jGot5mOmvIQrZueCnPtbYtRe2hqke4sGojm3zI,16
6
+ CacheToolsUtils-8.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
CacheToolsUtils.py CHANGED
@@ -2,7 +2,7 @@
2
2
  CacheTools Utilities. This code is public domain.
3
3
  """
4
4
 
5
- from typing import Any, Callable, MutableMapping as MutMap
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: MutMap
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: MutMap, log: logging.Logger, name="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, MutMap):
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: MutMap, lock):
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, MutMap):
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: MutMap, prefix: str|bytes = ""):
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, MutMap):
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: MutMap):
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, MutMap):
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: MutMap, cache2: MutMap, resilient=False):
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[[MutMap, str], MutMap]
373
+ MapGen = Callable[[MutableMapping, str], MutableMapping]
374
374
 
375
375
 
376
- def cacheMethods(cache: MutMap, obj: Any, gen: MapGen = PrefixedCache, **funs):
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: MutMap, globs: MutMap[str, Any], gen: MapGen = PrefixedCache, **funs
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, MutMap):
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(MutMap):
531
+ class RedisCache(MutableMapping):
532
532
  """Redis TTL-ed wrapper for cachetools (``redis``).
533
533
 
534
534
  :param cache: actual redis cache.
@@ -1,6 +0,0 @@
1
- CacheToolsUtils.py,sha256=RisKLtsf49plnqP3XIb4TdqPuNPdseGmma9tyVRSjc0,17969
2
- CacheToolsUtils-8.4.dist-info/LICENSE,sha256=y_yFW1bmBAUFCF-ZDyDiq10Ykns_19If5pFnZUzYgeU,33
3
- CacheToolsUtils-8.4.dist-info/METADATA,sha256=RvB7NTOT_3y56aCF0BXpenPKFhRScFH3cjCMSXO2lTY,4110
4
- CacheToolsUtils-8.4.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
5
- CacheToolsUtils-8.4.dist-info/top_level.txt,sha256=qCyE4jGot5mOmvIQrZueCnPtbYtRe2hqke4sGojm3zI,16
6
- CacheToolsUtils-8.4.dist-info/RECORD,,