zx80 / cachetools-utils Goto Github PK
View Code? Open in Web Editor NEWClasses to add key prefix and stats to cachetools classes and use redis and memcached backends
Home Page: https://zx80.github.io/cachetools-utils/
License: Other
Classes to add key prefix and stats to cachetools classes and use redis and memcached backends
Home Page: https://zx80.github.io/cachetools-utils/
License: Other
TwoLevelCache might not have a significant impact on latency in most cases but it would have on resiliency.
For example if we have a TwoLevelCache setup with the first level as a local in memory cache and the second layer using Redis or Memcached the cache could have a flag to ignore failures on the second level, so as long as the first level is available the app would remain functional.
This should probably be false by default and when set to true it would still log some warning, or maybe it can throw some custom exception that can be handled by the app and the developer can decide to ignore it or not.
Hi, I was trying to update my dependencies and started getting a KeyError
when using any 8.x version, I was using cachetools~=5.3.0
and CacheToolsUtils~=6.0
; tried to update to cachetools~=5.3.2
and CacheToolsUtils~=8.2
and started getting errors, the same code works fine with cachetools~=5.3.2
and CacheToolsUtils~=7.0
.
I'm using the TwoLevelCache
with a local map and Redis and the same error occurs regardless of setting resilient
to True
or not.
The error details, on the first call to the cached method (using the decorator):
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 68, in __getitem__
return self.__data[key]
KeyError: ('ca07b064874e1b243a8edab3ff97e9e32d1420dee27ca974fbf92a36e94dac72',)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 216, in __getitem__
return self._cache.__getitem__(key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 418, in __getitem__
return cache_getitem(self, key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 70, in __getitem__
return self.__missing__(key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 97, in __missing__
raise KeyError(key)
KeyError: ('ca07b064874e1b243a8edab3ff97e9e32d1420dee27ca974fbf92a36e94dac72',)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 219, in __getitem__
val = self._cache2.__getitem__(key)
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 488, in __getitem__
raise KeyError()
KeyError
and on the second call:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 68, in __getitem__
return self.__data[key]
KeyError: ('ca07b064874e1b243a8edab3ff97e9e32d1420dee27ca974fbf92a36e94dac72',)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 216, in __getitem__
return self._cache.__getitem__(key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 418, in __getitem__
return cache_getitem(self, key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 70, in __getitem__
return self.__missing__(key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 97, in __missing__
raise KeyError(key)
KeyError: ('ca07b064874e1b243a8edab3ff97e9e32d1420dee27ca974fbf92a36e94dac72',)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 219, in __getitem__
val = self._cache2.__getitem__(key)
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 488, in __getitem__
raise KeyError()
KeyError
{"asctime": "2023-11-08 18:04:01,481", "levelname": "INFO", "message": "find_ticket_by_hash received a request", "hash": "ca07b064874e1b243a8edab3ff97e9e32d1420dee27ca974fbf92a36e94dac72"}
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 68, in __getitem__
return self.__data[key]
KeyError: ('ca07b064874e1b243a8edab3ff97e9e32d1420dee27ca974fbf92a36e94dac72',)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 216, in __getitem__
return self._cache.__getitem__(key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 418, in __getitem__
return cache_getitem(self, key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 70, in __getitem__
return self.__missing__(key)
File "/usr/lib/python3.10/site-packages/cachetools/__init__.py", line 97, in __missing__
raise KeyError(key)
KeyError: ('ca07b064874e1b243a8edab3ff97e9e32d1420dee27ca974fbf92a36e94dac72',)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 219, in __getitem__
val = self._cache2.__getitem__(key)
File "/usr/lib/python3.10/site-packages/CacheToolsUtils.py", line 488, in __getitem__
raise KeyError()
KeyError
The fixme:
cachetools-utils/CacheToolsUtils.py
Line 278 in e64587c
Here they are defined: https://github.com/tkem/cachetools/blob/36b83c34afdc27df1a0c34f673b27ba06231c833/src/cachetools/__init__.py#L105
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.