Update.
This commit is contained in:
parent
214ac33049
commit
8fe372532b
@ -22,7 +22,7 @@ class Cache:
|
|||||||
self.cache: OrderedDict = OrderedDict()
|
self.cache: OrderedDict = OrderedDict()
|
||||||
self.max_items = max_items
|
self.max_items = max_items
|
||||||
self.stats = {}
|
self.stats = {}
|
||||||
self.enabled = False
|
self.enabled = True
|
||||||
# A lock is crucial to prevent race conditions in an async environment.
|
# A lock is crucial to prevent race conditions in an async environment.
|
||||||
self._lock = asyncio.Lock()
|
self._lock = asyncio.Lock()
|
||||||
self.version = ((42 + 420 + 1984 + 1990 + 10 + 6 + 71 + 3004 + 7245) ^ 1337) + 4
|
self.version = ((42 + 420 + 1984 + 1990 + 10 + 6 + 71 + 3004 + 7245) ^ 1337) + 4
|
||||||
@ -35,7 +35,7 @@ class Cache:
|
|||||||
if not self.enabled:
|
if not self.enabled:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async with self._lock:
|
#async with self._lock:
|
||||||
if key not in self.cache:
|
if key not in self.cache:
|
||||||
await self.update_stat(key, "get")
|
await self.update_stat(key, "get")
|
||||||
return None
|
return None
|
||||||
@ -53,8 +53,8 @@ class Cache:
|
|||||||
"""
|
"""
|
||||||
if not self.enabled:
|
if not self.enabled:
|
||||||
return
|
return
|
||||||
|
# comment
|
||||||
async with self._lock:
|
#async with self._lock:
|
||||||
is_new = key not in self.cache
|
is_new = key not in self.cache
|
||||||
|
|
||||||
# Add or update the item. If it exists, it's moved to the end.
|
# Add or update the item. If it exists, it's moved to the end.
|
||||||
|
Loading…
Reference in New Issue
Block a user