mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Use LRU cache by default
This commit is contained in:
parent
7148aaf5d0
commit
a89559d797
@ -57,7 +57,7 @@ cache_counter = metrics.register_cache(
|
|||||||
|
|
||||||
class Cache(object):
|
class Cache(object):
|
||||||
|
|
||||||
def __init__(self, name, max_entries=1000, keylen=1, lru=False):
|
def __init__(self, name, max_entries=1000, keylen=1, lru=True):
|
||||||
if lru:
|
if lru:
|
||||||
self.cache = LruCache(max_size=max_entries)
|
self.cache = LruCache(max_size=max_entries)
|
||||||
self.max_entries = None
|
self.max_entries = None
|
||||||
@ -141,7 +141,7 @@ class CacheDescriptor(object):
|
|||||||
which can be used to insert values into the cache specifically, without
|
which can be used to insert values into the cache specifically, without
|
||||||
calling the calculation function.
|
calling the calculation function.
|
||||||
"""
|
"""
|
||||||
def __init__(self, orig, max_entries=1000, num_args=1, lru=False):
|
def __init__(self, orig, max_entries=1000, num_args=1, lru=True):
|
||||||
self.orig = orig
|
self.orig = orig
|
||||||
|
|
||||||
self.max_entries = max_entries
|
self.max_entries = max_entries
|
||||||
@ -192,7 +192,7 @@ class CacheDescriptor(object):
|
|||||||
return wrapped
|
return wrapped
|
||||||
|
|
||||||
|
|
||||||
def cached(max_entries=1000, num_args=1, lru=False):
|
def cached(max_entries=1000, num_args=1, lru=True):
|
||||||
return lambda orig: CacheDescriptor(
|
return lambda orig: CacheDescriptor(
|
||||||
orig,
|
orig,
|
||||||
max_entries=max_entries,
|
max_entries=max_entries,
|
||||||
|
Loading…
Reference in New Issue
Block a user