@@ -17,6 +17,9 @@ class Averager:
17
17
Sometimes known as "online statistics," the running average maintains the
18
18
total and count. The average can then be calculated at any time.
19
19
20
+ Assumes the key will not be evicted. Set the eviction policy to 'none' on
21
+ the cache to guarantee the key is not evicted.
22
+
20
23
>>> import diskcache
21
24
>>> cache = diskcache.FanoutCache()
22
25
>>> ave = Averager(cache, 'latency')
@@ -65,6 +68,9 @@ def pop(self):
65
68
class Lock :
66
69
"""Recipe for cross-process and cross-thread lock.
67
70
71
+ Assumes the key will not be evicted. Set the eviction policy to 'none' on
72
+ the cache to guarantee the key is not evicted.
73
+
68
74
>>> import diskcache
69
75
>>> cache = diskcache.Cache()
70
76
>>> lock = Lock(cache, 'report-123')
@@ -113,6 +119,9 @@ def __exit__(self, *exc_info):
113
119
class RLock :
114
120
"""Recipe for cross-process and cross-thread re-entrant lock.
115
121
122
+ Assumes the key will not be evicted. Set the eviction policy to 'none' on
123
+ the cache to guarantee the key is not evicted.
124
+
116
125
>>> import diskcache
117
126
>>> cache = diskcache.Cache()
118
127
>>> rlock = RLock(cache, 'user-123')
@@ -181,6 +190,9 @@ def __exit__(self, *exc_info):
181
190
class BoundedSemaphore :
182
191
"""Recipe for cross-process and cross-thread bounded semaphore.
183
192
193
+ Assumes the key will not be evicted. Set the eviction policy to 'none' on
194
+ the cache to guarantee the key is not evicted.
195
+
184
196
>>> import diskcache
185
197
>>> cache = diskcache.Cache()
186
198
>>> semaphore = BoundedSemaphore(cache, 'max-cons', value=2)
@@ -251,6 +263,9 @@ def throttle(
251
263
):
252
264
"""Decorator to throttle calls to function.
253
265
266
+ Assumes keys will not be evicted. Set the eviction policy to 'none' on the
267
+ cache to guarantee the keys are not evicted.
268
+
254
269
>>> import diskcache, time
255
270
>>> cache = diskcache.Cache()
256
271
>>> count = 0
@@ -305,6 +320,9 @@ def barrier(cache, lock_factory, name=None, expire=None, tag=None):
305
320
306
321
Supports different kinds of locks: Lock, RLock, BoundedSemaphore.
307
322
323
+ Assumes keys will not be evicted. Set the eviction policy to 'none' on the
324
+ cache to guarantee the keys are not evicted.
325
+
308
326
>>> import diskcache, time
309
327
>>> cache = diskcache.Cache()
310
328
>>> @barrier(cache, Lock)
0 commit comments