Skip to content

Commit

Permalink
disable caching get_originals (88cbe3b) until bugs are fixed
Browse files Browse the repository at this point in the history
for #1149
  • Loading branch information
snarfed committed Jul 31, 2024
1 parent 6d7066c commit 3529216
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from urllib.parse import urljoin, urlparse

import cachetools
from cachetools.keys import hashkey
from Crypto.Util import number
from flask import abort, g, has_request_context, make_response, request
from google.cloud.error_reporting.util import build_flask_context
Expand Down Expand Up @@ -428,7 +427,7 @@ def memcache_memoize(expire=None):
def decorator(fn):
@functools.wraps(fn)
def wrapped(*args, **kwargs):
key = memcache_key(f'{fn.__name__}-{str(hashkey(*args, **kwargs))}')
key = memcache_key(f'{fn.__name__}-{repr(args)}-{repr(kwargs)}')
if val := memcache.get(key):
logger.debug(f'cache hit {key}')
return val
Expand Down
3 changes: 2 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,8 @@ def get_original(copy_id, keys_only=None):
return got[0]


@memcache_memoize(expire=60 * 60 * 24) # 1d
# TODO
# @memcache_memoize(expire=60 * 60) # 1h
def get_originals(copy_ids, keys_only=None):
"""Fetches users (across all protocols) for a given set of copies.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ def test_get_originals(self):
user = self.make_user('other:user', cls=OtherFake,
copies=[Target(uri='fake:bar', protocol='fake')])

memcache_key = "get_originals-(['other:foo',%20'fake:bar',%20'baz'],)"
memcache_key = "get_originals-(['other:foo',%20'fake:bar',%20'baz'],)-{}"
self.assertIsNone(common.memcache.get(memcache_key))

self.assert_entities_equal(
Expand Down

0 comments on commit 3529216

Please sign in to comment.