[Misc] Modify LRUCache touch (#16689)
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
parent
96bb8aa68b
commit
0d7d05f4b6
@ -316,7 +316,10 @@ class LRUCache(cachetools.LRUCache[_K, _V], Generic[_K, _V]):
|
||||
return info
|
||||
|
||||
def touch(self, key: _K) -> None:
|
||||
self._LRUCache__update(key) # type: ignore
|
||||
try:
|
||||
self._LRUCache__order.move_to_end(key) # type: ignore
|
||||
except KeyError:
|
||||
self._LRUCache__order[key] = None # type: ignore
|
||||
|
||||
@overload
|
||||
def get(self, key: _K, /) -> Optional[_V]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user