[Misc] Modify LRUCache touch (#16689)

Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
Jee Jee Li 2025-04-16 12:51:38 +08:00 committed by GitHub
parent 96bb8aa68b
commit 0d7d05f4b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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]: