Coder Social home page Coder Social logo

zx80 / cachetools-utils Goto Github PK

View Code? Open in Web Editor NEW
25.0 25.0 2.0 107 KB

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

Python 93.80% Makefile 6.20%
cache python

cachetools-utils's People

Contributors

zx80 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

risikaaps vsajip

cachetools-utils's Issues

Leverage TwoLevelCache for resiliency

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.

KeyError when using 8.x

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.