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.
Files changed (32) hide show
  1. {cachetools-6.2.4 → cachetools-6.2.5}/CHANGELOG.rst +11 -0
  2. {cachetools-6.2.4 → cachetools-6.2.5}/LICENSE +1 -1
  3. {cachetools-6.2.4/src/cachetools.egg-info → cachetools-6.2.5}/PKG-INFO +2 -2
  4. {cachetools-6.2.4 → cachetools-6.2.5}/README.rst +1 -1
  5. {cachetools-6.2.4 → cachetools-6.2.5}/docs/conf.py +1 -1
  6. {cachetools-6.2.4 → cachetools-6.2.5}/docs/index.rst +3 -2
  7. {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/__init__.py +1 -1
  8. {cachetools-6.2.4 → cachetools-6.2.5/src/cachetools.egg-info}/PKG-INFO +2 -2
  9. {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools.egg-info/SOURCES.txt +1 -0
  10. cachetools-6.2.5/tests/test_threading.py +49 -0
  11. {cachetools-6.2.4 → cachetools-6.2.5}/tox.ini +2 -0
  12. {cachetools-6.2.4 → cachetools-6.2.5}/MANIFEST.in +0 -0
  13. {cachetools-6.2.4 → cachetools-6.2.5}/pyproject.toml +0 -0
  14. {cachetools-6.2.4 → cachetools-6.2.5}/setup.cfg +0 -0
  15. {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/_cached.py +0 -0
  16. {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/_cachedmethod.py +0 -0
  17. {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/func.py +0 -0
  18. {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools/keys.py +0 -0
  19. {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools.egg-info/dependency_links.txt +0 -0
  20. {cachetools-6.2.4 → cachetools-6.2.5}/src/cachetools.egg-info/top_level.txt +0 -0
  21. {cachetools-6.2.4 → cachetools-6.2.5}/tests/__init__.py +0 -0
  22. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_cache.py +0 -0
  23. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_cached.py +0 -0
  24. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_cachedmethod.py +0 -0
  25. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_fifo.py +0 -0
  26. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_func.py +0 -0
  27. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_keys.py +0 -0
  28. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_lfu.py +0 -0
  29. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_lru.py +0 -0
  30. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_rr.py +0 -0
  31. {cachetools-6.2.4 → cachetools-6.2.5}/tests/test_tlru.py +0 -0
  32. {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
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2025 Thomas Kemmer
3
+ Copyright (c) 2014-2026 Thomas Kemmer
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cachetools
3
- Version: 6.2.4
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-2025 Thomas Kemmer.
130
+ Copyright (c) 2014-2026 Thomas Kemmer.
131
131
 
132
132
  Licensed under the `MIT License`_.
133
133
 
@@ -102,7 +102,7 @@ Related Projects
102
102
  License
103
103
  ------------------------------------------------------------------------
104
104
 
105
- Copyright (c) 2014-2025 Thomas Kemmer.
105
+ Copyright (c) 2014-2026 Thomas Kemmer.
106
106
 
107
107
  Licensed under the `MIT License`_.
108
108
 
@@ -19,7 +19,7 @@ def get_version():
19
19
 
20
20
 
21
21
  project = "cachetools"
22
- copyright = "2014-2025 Thomas Kemmer"
22
+ copyright = "2014-2026 Thomas Kemmer"
23
23
  release, version = get_version()
24
24
 
25
25
  extensions = [
@@ -572,14 +572,15 @@ often called with the same arguments:
572
572
  .. testcode::
573
573
 
574
574
  from cachetools.keys import hashkey
575
- from functools import partial
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
@@ -12,7 +12,7 @@ __all__ = (
12
12
  "cachedmethod",
13
13
  )
14
14
 
15
- __version__ = "6.2.4"
15
+ __version__ = "6.2.5"
16
16
 
17
17
  import collections
18
18
  import collections.abc
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cachetools
3
- Version: 6.2.4
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-2025 Thomas Kemmer.
130
+ Copyright (c) 2014-2026 Thomas Kemmer.
131
131
 
132
132
  Licensed under the `MIT License`_.
133
133
 
@@ -25,5 +25,6 @@ tests/test_keys.py
25
25
  tests/test_lfu.py
26
26
  tests/test_lru.py
27
27
  tests/test_rr.py
28
+ tests/test_threading.py
28
29
  tests/test_tlru.py
29
30
  tests/test_ttl.py
@@ -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)
@@ -5,6 +5,8 @@ envlist = check-manifest,docs,doctest,flake8,py
5
5
  deps =
6
6
  pytest
7
7
  pytest-cov
8
+ setenv =
9
+ THREADING_TESTS = 1
8
10
  commands =
9
11
  py.test --basetemp={envtmpdir} --cov=cachetools --cov-report term-missing {posargs}
10
12
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes