LockProtocol
SyncLockProtocol
SyncLockProtocol(
cache: CacheProtocol,
key: Any,
*,
timeout: float = ...,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...
)
Bases: Protocol
Recipe for cross-process and cross-thread lock.
Assumes the key will not be evicted. Set the eviction policy to 'none' on the cache to guarantee the key is not evicted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
CacheProtocol
|
Cache to use for lock. |
required |
|
Any
|
Key for lock. |
required |
|
float
|
Timeout for lock. |
...
|
|
float | None
|
Expiration time for lock. |
...
|
|
str | Iterable[str] | None
|
Tags for lock. |
...
|
Examples:
Source code in src/typed_diskcache/interface/sync.py
acquire
AsyncLockProtocol
AsyncLockProtocol(
cache: CacheProtocol,
key: Any,
*,
timeout: float = ...,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...
)
Bases: Protocol
Recipe for cross-process and cross-thread lock.
Assumes the key will not be evicted. Set the eviction policy to 'none' on the cache to guarantee the key is not evicted.
Asynchronous version of
SyncLockProtocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
CacheProtocol
|
Cache to use for lock. |
required |
|
Any
|
Key for lock. |
required |
|
float
|
Timeout for lock. |
...
|
|
float | None
|
Expiration time for lock. |
...
|
|
str | Iterable[str] | None
|
Tags for lock. |
...
|
Examples: