# HG changeset patch # User Marcin Kuzminski # Date 2018-07-12 15:48:12 # Node ID 7c75e32b84a460a93c60f1e7d60cfae754ee7af9 # Parent 00ce3d8774494171085476849036801e00c0be1b caches: use a faster LRUDict implementation for LRUMemoryCache diff --git a/pkgs/python-packages.nix b/pkgs/python-packages.nix --- a/pkgs/python-packages.nix +++ b/pkgs/python-packages.nix @@ -791,6 +791,17 @@ self: super: { license = [ pkgs.lib.licenses.bsdOriginal ]; }; }; + "lru-dict" = super.buildPythonPackage { + name = "lru-dict-1.1.6"; + doCheck = false; + src = fetchurl { + url = "https://files.pythonhosted.org/packages/00/a5/32ed6e10246cd341ca8cc205acea5d208e4053f48a4dced2b1b31d45ba3f/lru-dict-1.1.6.tar.gz"; + sha256 = "1k2lhd4dpl6xa6iialbwx4l6bkdzxmzhygms39pvf19x1rk5fm1n"; + }; + meta = { + license = [ pkgs.lib.licenses.mit ]; + }; + }; "lxml" = super.buildPythonPackage { name = "lxml-3.7.3"; doCheck = false; @@ -1668,6 +1679,7 @@ self: super: { self."billiard" self."kombu" self."lxml" + self."lru-dict" self."mako" self."markdown" self."markupsafe" diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -29,6 +29,7 @@ jinja2==2.9.6 billiard==3.5.0.3 kombu==4.2.0 lxml==3.7.3 +lru-dict==1.1.6 mako==1.0.7 markdown==2.6.11 markupsafe==1.0.0 diff --git a/rhodecode/lib/rc_cache/backends.py b/rhodecode/lib/rc_cache/backends.py --- a/rhodecode/lib/rc_cache/backends.py +++ b/rhodecode/lib/rc_cache/backends.py @@ -28,8 +28,8 @@ from dogpile.cache.backends import file from dogpile.cache.backends import redis as redis_backend from dogpile.cache.backends.file import NO_VALUE, compat, FileLock from dogpile.cache.util import memoized_property +from lru import LRU as LRUDict -from rhodecode.lib.memory_lru_debug import LRUDict _default_max_size = 1024 @@ -37,12 +37,22 @@ log = logging.getLogger(__name__) class LRUMemoryBackend(memory_backend.MemoryBackend): + pickle_values = False def __init__(self, arguments): max_size = arguments.pop('max_size', _default_max_size) arguments['cache_dict'] = LRUDict(max_size) super(LRUMemoryBackend, self).__init__(arguments) + def delete(self, key): + if self._cache.has_key(key): + del self._cache[key] + + def delete_multi(self, keys): + for key in keys: + if self._cache.has_key(key): + del self._cache[key] + class Serializer(object): def _dumps(self, value):