Skip to content

Commit e62212e

Browse files
committed
Remove CACHEOPS_LRU
1 parent ba86b3a commit e62212e

File tree

7 files changed

+3
-22
lines changed

7 files changed

+3
-22
lines changed

README.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,9 +705,6 @@ Redis however doesn't guarantee perfect TTL eviction order, it selects several k
705705
one with the least TTL, thus invalidator could be evicted before cache key it refers leaving it orphan and causing it survive next invalidation.
706706
You can reduce this chance by increasing ``maxmemory-samples`` redis config option and by reducing cache timeout.
707707

708-
Second strategy, probably more efficient one is adding ``CACHEOPS_LRU = True`` to your settings and then using ``maxmemory-policy volatile-lru``.
709-
However, this makes invalidation structures persistent, they are still removed on associated events, but in absence of them can clutter redis database.
710-
711708

712709
Keeping stats
713710
-------------

cacheops/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class Defaults:
1515
CACHEOPS_DEFAULTS = {}
1616
CACHEOPS = {}
1717
CACHEOPS_PREFIX = lambda query: ''
18-
CACHEOPS_LRU = False
1918
CACHEOPS_INSIDEOUT = False
2019
CACHEOPS_CLIENT_CLASS = None
2120
CACHEOPS_DEGRADE_ON_FAILURE = False

cacheops/getset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def cache_thing(prefix, cache_key, data, cond_dnfs, timeout, dbs=(), precall_key
4141
else:
4242
if prefix and precall_key == "":
4343
precall_key = prefix
44-
load_script('cache_thing', settings.CACHEOPS_LRU)(
44+
load_script('cache_thing')(
4545
keys=[prefix, cache_key, precall_key],
4646
args=[
4747
settings.CACHEOPS_SERIALIZER.dumps(data),

cacheops/lua/cache_thing.lua

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ for db_table, disj in pairs(dnfs) do
4747
redis.call('sadd', conj_key, key)
4848
-- NOTE: an invalidator should live longer than any key it references.
4949
-- So we update its ttl on every key if needed.
50-
-- NOTE: if CACHEOPS_LRU is True when invalidators should be left persistent,
51-
-- so we strip next section from this script.
52-
-- TOSTRIP
53-
local conj_ttl = redis.call('ttl', conj_key)
54-
if conj_ttl < timeout then
55-
-- We set conj_key life with a margin over key life to call expire rarer
56-
-- And add few extra seconds to be extra safe
57-
redis.call('expire', conj_key, timeout * 2 + 10)
58-
end
59-
-- /TOSTRIP
50+
redis.call('expire', conj_key, timeout, 'gt')
6051
end
6152
end

cacheops/redis.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,12 @@ def redis_client():
5353

5454
### Lua script loader
5555

56-
import re
5756
import os.path
5857

59-
STRIP_RE = re.compile(r'TOSTRIP.*/TOSTRIP', re.S)
6058

6159
@memoize
62-
def load_script(name, strip=False):
60+
def load_script(name):
6361
filename = os.path.join(os.path.dirname(__file__), 'lua/%s.lua' % name)
6462
with open(filename) as f:
6563
code = f.read()
66-
if strip:
67-
code = STRIP_RE.sub('', code)
6864
return redis_client.register_script(code)

tests/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
if os.environ.get('CACHEOPS_PREFIX'):
109109
CACHEOPS_PREFIX = lambda q: 'p:'
110110

111-
CACHEOPS_LRU = bool(os.environ.get('CACHEOPS_LRU'))
112111
CACHEOPS_INSIDEOUT = bool(os.environ.get('CACHEOPS_INSIDEOUT'))
113112
CACHEOPS_DEGRADE_ON_FAILURE = bool(os.environ.get('CACHEOPS_DEGRADE_ON_FAILURE'))
114113
ALLOWED_HOSTS = ['testserver']

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ deps =
4747
commands =
4848
./run_tests.py []
4949
env CACHEOPS_PREFIX=1 ./run_tests.py []
50-
env CACHEOPS_LRU=1 ./run_tests.py []
5150
env CACHEOPS_INSIDEOUT=1 ./run_tests.py []
5251
env CACHEOPS_DB=mysql ./run_tests.py []
5352
env CACHEOPS_DB=postgresql ./run_tests.py []

0 commit comments

Comments
 (0)