modify: 排他锁
This commit is contained in:
@@ -47,6 +47,10 @@ class DiskBackend(CacheBackend):
|
||||
def set(self, key, value, expire: float | None = None) -> None:
|
||||
self._cache.set(key, value, expire=expire)
|
||||
|
||||
def set_nx(self, key, value, expire: float | None = None) -> bool:
|
||||
# diskcache.add 仅在 key 不存在时写入,返回是否成功(SET NX 语义)且进程安全
|
||||
return bool(self._cache.add(key, value, expire=expire))
|
||||
|
||||
def touch(self, key, expire: float | None = None) -> bool:
|
||||
return self._cache.touch(key, expire=expire)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user