fix: start tracking keys set by us immediately
This commit is contained in:
parent
4518b4562f
commit
f332852415
2 changed files with 9 additions and 1 deletions
|
|
@ -31,7 +31,9 @@ class TestClientCache(IntegrationTestCase):
|
|||
# frappe.cache is our "another client"
|
||||
val = frappe.generate_hash()
|
||||
frappe.cache.set_value(TEST_KEY, val)
|
||||
time.sleep(0.5)
|
||||
# This is almost instant, but obviously not as fast as running the next instruction in
|
||||
# current thread. So we wait.
|
||||
time.sleep(0.1)
|
||||
|
||||
with self.assertRedisCallCounts(1):
|
||||
self.assertEqual(frappe.client_cache.get_value(TEST_KEY), val)
|
||||
|
|
|
|||
|
|
@ -462,6 +462,12 @@ class _ClientCache:
|
|||
key = self.redis.make_key(key)
|
||||
self.redis.set_value(key, val, shared=True)
|
||||
self.local_cache[key] = (val, time.monotonic() + self.local_ttl)
|
||||
# XXX: We need to tell redis that we indeed read this key we just wrote
|
||||
# This is an edge case:
|
||||
# - Client A writes a key and reads it again from local cache
|
||||
# - Client B overwrites this key, but since client A never "read" it from Redis, Redis
|
||||
# doesn't send invalidation.
|
||||
_ = self.redis.get_value(key, shared=True, use_local_cache=False)
|
||||
|
||||
def delete_value(self, key):
|
||||
key = self.redis.make_key(key)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue