cachetools 6.2.0__tar.gz → 6.2.1__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.0 → cachetools-6.2.1}/CHANGELOG.rst +10 -0
- {cachetools-6.2.0/src/cachetools.egg-info → cachetools-6.2.1}/PKG-INFO +2 -1
- {cachetools-6.2.0 → cachetools-6.2.1}/docs/index.rst +48 -4
- {cachetools-6.2.0 → cachetools-6.2.1}/setup.cfg +1 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/src/cachetools/__init__.py +1 -1
- {cachetools-6.2.0 → cachetools-6.2.1}/src/cachetools/func.py +1 -0
- {cachetools-6.2.0 → cachetools-6.2.1/src/cachetools.egg-info}/PKG-INFO +2 -1
- {cachetools-6.2.0 → cachetools-6.2.1}/LICENSE +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/MANIFEST.in +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/README.rst +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/docs/conf.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/pyproject.toml +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/setup.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/src/cachetools/_cached.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/src/cachetools/_cachedmethod.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/src/cachetools/keys.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/src/cachetools.egg-info/SOURCES.txt +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/src/cachetools.egg-info/dependency_links.txt +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/src/cachetools.egg-info/top_level.txt +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/__init__.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_cache.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_cached.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_cachedmethod.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_fifo.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_func.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_keys.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_lfu.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_lru.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_rr.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_tlru.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tests/test_ttl.py +0 -0
- {cachetools-6.2.0 → cachetools-6.2.1}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cachetools
|
|
3
|
-
Version: 6.2.
|
|
3
|
+
Version: 6.2.1
|
|
4
4
|
Summary: Extensible memoizing collections and decorators
|
|
5
5
|
Home-page: https://github.com/tkem/cachetools/
|
|
6
6
|
Author: Thomas Kemmer
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
23
|
Requires-Python: >=3.9
|
|
23
24
|
License-File: LICENSE
|
|
@@ -350,7 +350,7 @@ often called with the same arguments:
|
|
|
350
350
|
`cache stampede`_ issues under high load, depending on your
|
|
351
351
|
actual use case. Providing a `condition` variable will mitigate
|
|
352
352
|
these situations, but will inflict some performance penalty.
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
If no separate `lock` parameter is provided, `condition` must also
|
|
355
355
|
implement the `context manager`_ protocol, and will also be used to
|
|
356
356
|
guard access to the cache.
|
|
@@ -451,7 +451,7 @@ often called with the same arguments:
|
|
|
451
451
|
[..., (('fib', 42), 267914296), ..., (('luc', 42), 599074578)]
|
|
452
452
|
|
|
453
453
|
|
|
454
|
-
Function invocations are
|
|
454
|
+
Function invocations are *not* cached if any exceptions are raised.
|
|
455
455
|
To cache some (or all) calls raising exceptions, additional
|
|
456
456
|
function wrappers may be introduced which wrap exceptions as
|
|
457
457
|
regular function results for caching purposes:
|
|
@@ -488,6 +488,49 @@ often called with the same arguments:
|
|
|
488
488
|
print(e, "-", _get_pep_wrapped.cache_info())
|
|
489
489
|
|
|
490
490
|
|
|
491
|
+
Curiously, default function arguments are not quite handled as one
|
|
492
|
+
might expect, and also the use of positional vs. keyword arguments
|
|
493
|
+
may lead to surprising results. In the example below, `foo()`,
|
|
494
|
+
`foo(1)` and `foo(a=1)` are treated as different function
|
|
495
|
+
invocations, with seperately cached results:
|
|
496
|
+
|
|
497
|
+
.. doctest::
|
|
498
|
+
:pyversion: >= 3
|
|
499
|
+
|
|
500
|
+
>>> @cached(LRUCache(maxsize=100))
|
|
501
|
+
... def foo(a=1):
|
|
502
|
+
... print(f"foo({a}) called")
|
|
503
|
+
...
|
|
504
|
+
>>> foo()
|
|
505
|
+
foo(1) called
|
|
506
|
+
>>> foo()
|
|
507
|
+
>>> foo(1)
|
|
508
|
+
foo(1) called
|
|
509
|
+
>>> foo(1)
|
|
510
|
+
>>> foo(a=1)
|
|
511
|
+
foo(1) called
|
|
512
|
+
>>> foo(a=1)
|
|
513
|
+
|
|
514
|
+
If consistent behavior is required, a private helper function may
|
|
515
|
+
be introduced to avoid ambiguities, e.g.:
|
|
516
|
+
|
|
517
|
+
.. doctest::
|
|
518
|
+
:pyversion: >= 3
|
|
519
|
+
|
|
520
|
+
>>> def foo(a=1):
|
|
521
|
+
... _foo(a)
|
|
522
|
+
...
|
|
523
|
+
>>> @cached(LRUCache(maxsize=100))
|
|
524
|
+
... def _foo(a):
|
|
525
|
+
... print(f"_foo({a}) called")
|
|
526
|
+
...
|
|
527
|
+
>>> foo()
|
|
528
|
+
_foo(1) called
|
|
529
|
+
>>> foo()
|
|
530
|
+
>>> foo(1)
|
|
531
|
+
>>> foo(a=1)
|
|
532
|
+
|
|
533
|
+
|
|
491
534
|
.. decorator:: cachedmethod(cache, key=cachetools.keys.methodkey, lock=None, condition=None)
|
|
492
535
|
|
|
493
536
|
Decorator to wrap a class or instance method with a memoizing
|
|
@@ -731,8 +774,9 @@ all the decorators in this module are thread-safe by default.
|
|
|
731
774
|
|
|
732
775
|
Decorator to wrap a function with a memoizing callable that saves
|
|
733
776
|
up to `maxsize` results based on a Least Recently Used (LRU)
|
|
734
|
-
algorithm with a per-item time-to-live (TTL) value.
|
|
735
|
-
|
|
777
|
+
algorithm with a per-item time-to-live (TTL) value. By default,
|
|
778
|
+
the time-to-live is set to 600 seconds and :func:`time.monotonic`
|
|
779
|
+
is used to retrieve the current time.
|
|
736
780
|
|
|
737
781
|
.. _@lru_cache: https://docs.python.org/3/library/functools.html#functools.lru_cache
|
|
738
782
|
.. _cache algorithm: https://en.wikipedia.org/wiki/Cache_algorithms
|
|
@@ -92,6 +92,7 @@ def ttl_cache(maxsize=128, ttl=600, timer=time.monotonic, typed=False):
|
|
|
92
92
|
"""Decorator to wrap a function with a memoizing callable that saves
|
|
93
93
|
up to `maxsize` results based on a Least Recently Used (LRU)
|
|
94
94
|
algorithm with a per-item time-to-live (TTL) value.
|
|
95
|
+
|
|
95
96
|
"""
|
|
96
97
|
if maxsize is None:
|
|
97
98
|
return _cache(_UnboundTTLCache(ttl, timer), None, typed)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cachetools
|
|
3
|
-
Version: 6.2.
|
|
3
|
+
Version: 6.2.1
|
|
4
4
|
Summary: Extensible memoizing collections and decorators
|
|
5
5
|
Home-page: https://github.com/tkem/cachetools/
|
|
6
6
|
Author: Thomas Kemmer
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
23
|
Requires-Python: >=3.9
|
|
23
24
|
License-File: LICENSE
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|