cachetools 6.2.4__tar.gz → 6.2.5__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.
- {cachetools-6.2.4 → cachetools-6.2.5}/CHANGELOG.rst +11 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/LICENSE +1 -1
- {cachetools-6.2.4/src/cachetools.egg-info → cachetools-6.2.5}/PKG-INFO +2 -2
- {cachetools-6.2.4 → cachetools-6.2.5}/README.rst +1 -1
- {cachetools-6.2.4 → cachetools-6.2.5}/docs/conf.py +1 -1
- {cachetools-6.2.4 → cachetools-6.2.5}/docs/index.rst +3 -2
- {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/__init__.py +1 -1
- {cachetools-6.2.4 → cachetools-6.2.5/src/cachetools.egg-info}/PKG-INFO +2 -2
- {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools.egg-info/SOURCES.txt +1 -0
- cachetools-6.2.5/tests/test_threading.py +49 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tox.ini +2 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/MANIFEST.in +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/pyproject.toml +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/setup.cfg +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/_cached.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/_cachedmethod.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/func.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/keys.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools.egg-info/dependency_links.txt +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools.egg-info/top_level.txt +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/__init__.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_cache.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_cached.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_cachedmethod.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_fifo.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_func.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_keys.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_lfu.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_lru.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_rr.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_tlru.py +0 -0
- {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_ttl.py +0 -0
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
v6.2.5 (2026-01-25)
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
- Improve documentation regarding ``@cachedmethod`` with ``lock``
|
|
5
|
+
parameter.
|
|
6
|
+
|
|
7
|
+
- Add test cases for cache stampede scenarios.
|
|
8
|
+
|
|
9
|
+
- Update CI environment.
|
|
10
|
+
|
|
11
|
+
|
|
1
12
|
v6.2.4 (2025-12-15)
|
|
2
13
|
===================
|
|
3
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cachetools
|
|
3
|
-
Version: 6.2.
|
|
3
|
+
Version: 6.2.5
|
|
4
4
|
Summary: Extensible memoizing collections and decorators
|
|
5
5
|
Author-email: Thomas Kemmer <tkemmer@computer.org>
|
|
6
6
|
Maintainer-email: Thomas Kemmer <tkemmer@computer.org>
|
|
@@ -127,7 +127,7 @@ Related Projects
|
|
|
127
127
|
License
|
|
128
128
|
------------------------------------------------------------------------
|
|
129
129
|
|
|
130
|
-
Copyright (c) 2014-
|
|
130
|
+
Copyright (c) 2014-2026 Thomas Kemmer.
|
|
131
131
|
|
|
132
132
|
Licensed under the `MIT License`_.
|
|
133
133
|
|
|
@@ -572,14 +572,15 @@ often called with the same arguments:
|
|
|
572
572
|
.. testcode::
|
|
573
573
|
|
|
574
574
|
from cachetools.keys import hashkey
|
|
575
|
-
from
|
|
575
|
+
from threading import Lock
|
|
576
576
|
|
|
577
577
|
class CachedPEPs:
|
|
578
578
|
|
|
579
579
|
def __init__(self, cachesize):
|
|
580
580
|
self.cache = LRUCache(maxsize=cachesize)
|
|
581
|
+
self.lock = Lock()
|
|
581
582
|
|
|
582
|
-
@cachedmethod(lambda self: self.cache)
|
|
583
|
+
@cachedmethod(lambda self: self.cache, lock=lambda self: self.lock)
|
|
583
584
|
def get(self, num):
|
|
584
585
|
"""Retrieve text of a Python Enhancement Proposal"""
|
|
585
586
|
url = 'http://www.python.org/dev/peps/pep-%04d/' % num
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cachetools
|
|
3
|
-
Version: 6.2.
|
|
3
|
+
Version: 6.2.5
|
|
4
4
|
Summary: Extensible memoizing collections and decorators
|
|
5
5
|
Author-email: Thomas Kemmer <tkemmer@computer.org>
|
|
6
6
|
Maintainer-email: Thomas Kemmer <tkemmer@computer.org>
|
|
@@ -127,7 +127,7 @@ Related Projects
|
|
|
127
127
|
License
|
|
128
128
|
------------------------------------------------------------------------
|
|
129
129
|
|
|
130
|
-
Copyright (c) 2014-
|
|
130
|
+
Copyright (c) 2014-2026 Thomas Kemmer.
|
|
131
131
|
|
|
132
132
|
Licensed under the `MIT License`_.
|
|
133
133
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
import time
|
|
3
|
+
import unittest
|
|
4
|
+
from os import environ
|
|
5
|
+
|
|
6
|
+
from cachetools import LRUCache, cached, cachedmethod
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@unittest.skipUnless(environ.get("THREADING_TESTS", False), "THREADING_TESTS not set")
|
|
10
|
+
class ThreadingTest(unittest.TestCase):
|
|
11
|
+
|
|
12
|
+
NTHREADS = 10
|
|
13
|
+
|
|
14
|
+
cache = LRUCache(1)
|
|
15
|
+
|
|
16
|
+
cond = threading.Condition()
|
|
17
|
+
|
|
18
|
+
count = 0
|
|
19
|
+
|
|
20
|
+
@cached(cache=LRUCache(1), condition=threading.Condition(), info=True)
|
|
21
|
+
def func(self):
|
|
22
|
+
time.sleep(1.0)
|
|
23
|
+
return 42
|
|
24
|
+
|
|
25
|
+
@cachedmethod(cache=lambda self: self.cache, condition=lambda self: self.cond)
|
|
26
|
+
def meth(self):
|
|
27
|
+
time.sleep(1.0)
|
|
28
|
+
self.count += 1
|
|
29
|
+
return 42
|
|
30
|
+
|
|
31
|
+
def test_cached_stampede(self):
|
|
32
|
+
threads = [threading.Thread(target=self.func) for i in range(0, self.NTHREADS)]
|
|
33
|
+
for t in threads:
|
|
34
|
+
t.start()
|
|
35
|
+
for t in threads:
|
|
36
|
+
t.join()
|
|
37
|
+
|
|
38
|
+
info = self.func.cache_info()
|
|
39
|
+
self.assertEqual(info.hits, self.NTHREADS - 1)
|
|
40
|
+
self.assertEqual(info.misses, 1)
|
|
41
|
+
|
|
42
|
+
def test_cachedmethod_stampede(self):
|
|
43
|
+
threads = [threading.Thread(target=self.meth) for i in range(0, self.NTHREADS)]
|
|
44
|
+
for t in threads:
|
|
45
|
+
t.start()
|
|
46
|
+
for t in threads:
|
|
47
|
+
t.join()
|
|
48
|
+
|
|
49
|
+
self.assertEqual(self.count, 1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|