mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 00:54:57 -04:00
Replace DeferredCache with LruCache where possible (#8563)
Most of these uses don't need a full-blown DeferredCache; LruCache is lighter and more appropriate.
This commit is contained in:
parent
79c1f973ce
commit
97647b33c2
8 changed files with 30 additions and 27 deletions
|
@ -34,8 +34,8 @@ from synapse.storage.database import (
|
|||
)
|
||||
from synapse.types import Collection, JsonDict, get_verify_key_from_cross_signing_key
|
||||
from synapse.util import json_decoder, json_encoder
|
||||
from synapse.util.caches.deferred_cache import DeferredCache
|
||||
from synapse.util.caches.descriptors import cached, cachedList
|
||||
from synapse.util.caches.lrucache import LruCache
|
||||
from synapse.util.iterutils import batch_iter
|
||||
from synapse.util.stringutils import shortstr
|
||||
|
||||
|
@ -1005,8 +1005,8 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore):
|
|||
|
||||
# Map of (user_id, device_id) -> bool. If there is an entry that implies
|
||||
# the device exists.
|
||||
self.device_id_exists_cache = DeferredCache(
|
||||
name="device_id_exists", keylen=2, max_entries=10000
|
||||
self.device_id_exists_cache = LruCache(
|
||||
cache_name="device_id_exists", keylen=2, max_size=10000
|
||||
)
|
||||
|
||||
async def store_device(
|
||||
|
@ -1052,7 +1052,7 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore):
|
|||
)
|
||||
if hidden:
|
||||
raise StoreError(400, "The device ID is in use", Codes.FORBIDDEN)
|
||||
self.device_id_exists_cache.prefill(key, True)
|
||||
self.device_id_exists_cache.set(key, True)
|
||||
return inserted
|
||||
except StoreError:
|
||||
raise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue