28
28
29
29
30
30
class _MutMapMix :
31
- """Convenient MutableMapping Mixin, forward to _cache."""
31
+ """Convenient MutableMapping Mixin, forward to ` _cache` ."""
32
32
33
33
# FIXME coverage reports this as missing with Python 3.14
34
34
_cache : MutableMapping # pragma: no cover
@@ -53,7 +53,7 @@ def __iter__(self):
53
53
54
54
55
55
class _KeyMutMapMix (_MutMapMix ):
56
- """Convenient MutableMapping Mixin with a key filter, forward to _cache."""
56
+ """Convenient MutableMapping Mixin with a key filter, forward to ` _cache` ."""
57
57
58
58
@abc .abstractmethod
59
59
def _key (self , key : Any ) -> Any : # pragma: no cover
@@ -73,7 +73,7 @@ def __delitem__(self, key: Any):
73
73
74
74
75
75
class _StatsMix :
76
- """Convenient Mixin to forward stats methods to _cache."""
76
+ """Convenient Mixin to forward stats methods to ` _cache` ."""
77
77
78
78
def hits (self ) -> float | None :
79
79
return self ._cache .hits () # type: ignore
@@ -114,9 +114,11 @@ def dbsize(self, *args, **kwargs):
114
114
class DebugCache (_StatsMix , MutableMapping ):
115
115
"""Debug class.
116
116
117
- :param cache: actual cache
118
- :param log: logging instance
119
- :param name: name of instance for output
117
+ Parameters:
118
+
119
+ - cache: actual cache
120
+ - log: logging instance
121
+ - name: name of instance for output
120
122
"""
121
123
122
124
def __init__ (self , cache : MutableMapping , log : logging .Logger , name = "cache" ):
@@ -162,7 +164,7 @@ def reset(self): # pragma: no cover
162
164
163
165
164
166
class DictCache (_MutMapMix , MutableMapping ):
165
- """Cache class based on dict."""
167
+ """Cache class based on ` dict` ."""
166
168
167
169
def __init__ (self ):
168
170
self ._cache = dict ()
@@ -174,17 +176,19 @@ def clear(self):
174
176
class LockedCache (_MutMapMix , _StatsMix , _RedisMix , MutableMapping ):
175
177
"""Cache class with a lock.
176
178
177
- :param cache: actual cache.
178
- :param lock: lock (context manager) to use
179
+ Parameters:
179
180
180
- The locked layer should be the last one before the actual cache.
181
+ - cache: actual cache.
182
+ - lock: lock (context manager) to use
181
183
182
- .. code-block: python
184
+ The locked layer should be the last one before the actual cache.
183
185
184
- import threading
185
- import cachetools as ct
186
- import CacheToolsUtils as ctu
187
- cache = ctu.LockedCache(ct.LFUCache(), threading.RLock())
186
+ ```python
187
+ import threading
188
+ import cachetools as ct
189
+ import CacheToolsUtils as ctu
190
+ cache = ctu.LockedCache(ct.LFUCache(), threading.RLock())
191
+ ```
188
192
"""
189
193
190
194
def __init__ (self , cache : MutableMapping , lock ):
0 commit comments