CacheProtocol
CacheProtocol
CacheProtocol(
directory: str | PathLike[str] | None = ...,
disk_type: (
type[DiskProtocol]
| Callable[..., DiskProtocol]
| None
) = ...,
disk_args: Mapping[str, Any] | None = ...,
**kwargs: Unpack[SettingsKwargs]
)
Bases: Protocol
Disk and file backed cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | PathLike[str] | None
|
directory for cache |
...
|
|
type[DiskProtocol] | Callable[..., DiskProtocol] | None
|
|
...
|
|
Mapping[str, Any] | None
|
keyword arguments for |
...
|
|
Unpack[SettingsKwargs]
|
additional keyword arguments for
|
{}
|
Source code in src/typed_diskcache/interface/cache.py
get
Retrieve value from cache.
If key is missing, return container with default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
Any
|
Value to return if key is missing. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value or default if key not found. |
Source code in src/typed_diskcache/interface/cache.py
aget
async
Asynchronously retrieve value from cache.
If key is missing, return container with default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
Any
|
Value to return if key is missing. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value or default if key not found. |
Source code in src/typed_diskcache/interface/cache.py
set
set(
key: Any,
value: Any,
*,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...,
retry: bool = ...
) -> bool
Set key and value in cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
Any
|
Value for item. |
required |
|
float | None
|
Seconds until item expires. |
...
|
|
str | Iterable[str] | None
|
Tags to associate with key. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
bool
|
True if item was set. |
Source code in src/typed_diskcache/interface/cache.py
aset
async
aset(
key: Any,
value: Any,
*,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...,
retry: bool = ...
) -> bool
Asynchronously set key and value in cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
Any
|
Value for item. |
required |
|
float | None
|
Seconds until item expires. |
...
|
|
str | Iterable[str] | None
|
Tags to associate with key. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
bool
|
True if item was set. |
Source code in src/typed_diskcache/interface/cache.py
delete
Delete corresponding item for key from cache.
Missing keys are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key matching item. |
required |
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
bool
|
True if item was deleted. |
Source code in src/typed_diskcache/interface/cache.py
adelete
async
Asynchronously delete corresponding item for key from cache.
Missing keys are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key matching item. |
required |
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
bool
|
True if item was deleted. |
Source code in src/typed_diskcache/interface/cache.py
clear
Remove all items from cache.
Removing items is iterative. Each iteration removes a subset of items. Concurrent writes may occur.
If a TimeoutError occurs, the first element of the exception's args
attribute will be the number of items removed before the exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Count of rows removed. |
Source code in src/typed_diskcache/interface/cache.py
aclear
async
Asynchronously remove all items from cache.
Removing items is iterative. Each iteration removes a subset of items. Concurrent writes may occur.
If a TimeoutError occurs, the first element of the exception's args
attribute will be the number of items removed before the exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Count of rows removed. |
Source code in src/typed_diskcache/interface/cache.py
stats
astats
async
volume
volume() -> int
avolume
async
avolume() -> int
Asynchronously return estimated total size of cache on disk.
Returns:
| Type | Description |
|---|---|
int
|
Size in bytes. |
close
aclose
async
touch
Touch key in cache and update expire time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
float | None
|
Seconds until item expires. If None, no expiry. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
bool
|
True if key was touched. |
Source code in src/typed_diskcache/interface/cache.py
atouch
async
Asynchronously touch key in cache and update expire time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
float | None
|
Seconds until item expires. If None, no expiry. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
bool
|
True if key was touched. |
Source code in src/typed_diskcache/interface/cache.py
add
add(
key: Any,
value: Any,
*,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...,
retry: bool = ...
) -> bool
Add key and value item to cache.
Similar to set, but only add to cache if key not present.
Operation is atomic. Only one concurrent add operation for a given key will succeed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
Any
|
Value for item. |
required |
|
float | None
|
Seconds until the key expires. If None, no expiry. |
...
|
|
str | Iterable[str] | None
|
Tags to associate with key. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
bool
|
True if item was added. |
Source code in src/typed_diskcache/interface/cache.py
aadd
async
aadd(
key: Any,
value: Any,
*,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...,
retry: bool = ...
) -> bool
Asynchronously add key and value item to cache.
Similar to set, but only add to cache if key not present.
Operation is atomic. Only one concurrent add operation for a given key will succeed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
Any
|
Value for item. |
required |
|
float | None
|
Seconds until the key expires. If None, no expiry. |
...
|
|
str | Iterable[str] | None
|
Tags to associate with key. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
bool
|
True if item was added. |
Source code in src/typed_diskcache/interface/cache.py
pop
Remove corresponding item for key from cache and return value.
If key is missing, return default.
Operation is atomic. Concurrent operations will be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
Any
|
Value to return if key is missing. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value or default if key not found. |
Source code in src/typed_diskcache/interface/cache.py
apop
async
Asynchronously remove corresponding item for key from cache and return value.
If key is missing, return default.
Operation is atomic. Concurrent operations will be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
Any
|
Value to return if key is missing. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value or default if key not found. |
Source code in src/typed_diskcache/interface/cache.py
filter
filter(
tags: str | Iterable[str],
*,
method: FilterMethodLiteral | FilterMethod = ...
) -> Generator[Any, None, None]
Filter by tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Iterable[str]
|
Tags to filter by. |
required |
|
FilterMethodLiteral | FilterMethod
|
'and' or 'or' filter method. |
...
|
Yields:
| Type | Description |
|---|---|
Any
|
Key of item matching tags. |
Warning
This method is unstable and will be improved in the future.
Source code in src/typed_diskcache/interface/cache.py
afilter
afilter(
tags: str | Iterable[str],
*,
method: FilterMethodLiteral | FilterMethod = ...
) -> AsyncGenerator[Any, None]
Asynchronously filter by tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Iterable[str]
|
Tags to filter by. |
required |
|
FilterMethodLiteral | FilterMethod
|
'and' or 'or' filter method. |
...
|
Yields:
| Type | Description |
|---|---|
AsyncGenerator[Any, None]
|
Key of item matching tags. |
Warning
This method is unstable and will be improved in the future.
Source code in src/typed_diskcache/interface/cache.py
incr
Increment value by delta for item with key.
If key is missing and default is None then raise KeyError. Else if key
is missing and default is not None then use default for value.
Operation is atomic. All concurrent increment operations will be counted individually.
Assumes value may be stored in a SQLite column. Most builds that target machines with 64-bit pointer widths will support 64-bit signed integers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
int
|
Amount to increment. |
...
|
|
int | None
|
Value if key is missing. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Incremented value or default if key not found. |
Source code in src/typed_diskcache/interface/cache.py
aincr
async
Async increment value by delta for item with key.
If key is missing and default is None then raise [KeyError]. Else if key
is missing and default is not None then use default for value.
Operation is atomic. All concurrent increment operations will be counted individually.
Assumes value may be stored in a SQLite column. Most builds that target machines with 64-bit pointer widths will support 64-bit signed integers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
int
|
Amount to increment. |
...
|
|
int | None
|
Value if key is missing. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Incremented value or default if key not found. |
Source code in src/typed_diskcache/interface/cache.py
decr
Decrement value by delta for item with key.
If key is missing and default is None then raise KeyError. Else if key
is missing and default is not None then use default for value.
Operation is atomic. All concurrent decrement operations will be counted individually.
Unlike Memcached, negative values are supported. Value may be decremented below zero.
Assumes value may be stored in a SQLite column. Most builds that target machines with 64-bit pointer widths will support 64-bit signed integers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
int
|
Amount to decrement. |
...
|
|
int | None
|
Value if key is missing. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Decremented value or default if key not found. |
Source code in src/typed_diskcache/interface/cache.py
adecr
async
Async decrement value by delta for item with key.
If key is missing and default is None then raise KeyError. Else if key
is missing and default is not None then use default for value.
Operation is atomic. All concurrent decrement operations will be counted individually.
Unlike Memcached, negative values are supported. Value may be decremented below zero.
Assumes value may be stored in a SQLite column. Most builds that target machines with 64-bit pointer widths will support 64-bit signed integers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Key for item. |
required |
|
int
|
Amount to decrement. |
...
|
|
int | None
|
Value if key is missing. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Decremented value or default if key not found. |
Source code in src/typed_diskcache/interface/cache.py
evict
evict(
tags: str | Iterable[str],
*,
method: FilterMethodLiteral | FilterMethod = ...,
retry: bool = False
) -> int
Remove items with matching tag from cache.
Removing items is an iterative process. In each iteration, a subset of items is removed. Concurrent writes may occur between iterations.
If a TimeoutError occurs, the first element of the exception's
args attribute will be the number of items removed before the
exception occurred.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Iterable[str]
|
Tags identifying items. |
required |
|
FilterMethodLiteral | FilterMethod
|
'and' or 'or' filter method. |
...
|
|
bool
|
Retry if database timeout occurs. |
False
|
Returns:
| Type | Description |
|---|---|
int
|
Count of rows removed. |
Source code in src/typed_diskcache/interface/cache.py
aevict
async
aevict(
tags: str | Iterable[str],
*,
method: FilterMethodLiteral | FilterMethod = ...,
retry: bool = False
) -> int
Async remove items with matching tag from cache.
Removing items is an iterative process. In each iteration, a subset of items is removed. Concurrent writes may occur between iterations.
If a TimeoutError occurs, the first element of the exception's
args attribute will be the number of items removed before the
exception occurred.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Iterable[str]
|
Tags identifying items. |
required |
|
FilterMethodLiteral | FilterMethod
|
'and' or 'or' filter method. |
...
|
|
bool
|
Retry if database timeout occurs. |
False
|
Returns:
| Type | Description |
|---|---|
int
|
Count of rows removed. |
Source code in src/typed_diskcache/interface/cache.py
expire
Remove expired items from cache.
Removing items is an iterative process. In each iteration, a subset of items is removed. Concurrent writes may occur between iterations.
If a TimeoutError occurs, the first element of the exception's
args attribute will be the number of items removed before the
exception occurred.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float | None
|
Current time. If None, use |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Count of items removed. |
Source code in src/typed_diskcache/interface/cache.py
aexpire
async
Async remove expired items from cache.
Removing items is an iterative process. In each iteration, a subset of items is removed. Concurrent writes may occur between iterations.
If a TimeoutError occurs, the first element of the exception's
args attribute will be the number of items removed before the
exception occurred.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float | None
|
Current time. If None, use |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Count of items removed. |
Source code in src/typed_diskcache/interface/cache.py
cull
Cull items from cache until volume is less than size limit.
Removing items is an iterative process. In each iteration, a subset of items is removed. Concurrent writes may occur between iterations.
If a TimeoutError occurs, the first element of the exception's
args attribute will be the number of items removed before the
exception occurred.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Count of items removed. |
Source code in src/typed_diskcache/interface/cache.py
acull
async
Async cull items from cache until volume is less than size limit.
Removing items is an iterative process. In each iteration, a subset of items is removed. Concurrent writes may occur between iterations.
If a TimeoutError occurs, the first element of the exception's
args attribute will be the number of items removed before the
exception occurred.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
int
|
Count of items removed. |
Source code in src/typed_diskcache/interface/cache.py
push
push(
value: Any,
*,
prefix: str | None = ...,
side: QueueSideLiteral | QueueSide = ...,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...,
retry: bool = ...
) -> Any
Push value onto side of queue identified by prefix in cache.
When prefix is None, integer keys are used. Otherwise, string keys are used.
Operation is atomic. Concurrent operations will be serialized.
See also pull.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Value for item. |
required |
|
str | None
|
Key prefix. If None, key is integer. |
...
|
|
QueueSideLiteral | QueueSide
|
Either 'back' or 'front'. |
...
|
|
float | None
|
Seconds until the key expires. If None, no expiry. |
...
|
|
str | Iterable[str] | None
|
Tags to associate with key. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Any
|
Key of the pushed item. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
apush
async
apush(
value: Any,
*,
prefix: str | None = ...,
side: QueueSideLiteral | QueueSide = ...,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...,
retry: bool = ...
) -> Any
Async push value onto side of queue identified by prefix in cache.
When prefix is None, integer keys are used. Otherwise, string keys are used.
Operation is atomic. Concurrent operations will be serialized.
See also apull.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Value for item. |
required |
|
str | None
|
Key prefix. If None, key is integer. |
...
|
|
QueueSideLiteral | QueueSide
|
Either 'back' or 'front'. |
...
|
|
float | None
|
Seconds until the key expires. If None, no expiry. |
...
|
|
str | Iterable[str] | None
|
Tags to associate with key. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Any
|
Key of the pushed item. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
pull
pull(
*,
prefix: str | None = ...,
default: None,
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any | None]
pull(
*,
prefix: str | None = ...,
default: tuple[Any, _AnyT],
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any | _AnyT]
pull(
*,
prefix: str | None = ...,
default: tuple[Any, Any] | None = ...,
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any]
Pull key and value item pair from side of queue in cache.
When prefix is None, integer keys are used. Otherwise, string keys are used.
If queue is empty, return default.
Operation is atomic. Concurrent operations will be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | None
|
Key prefix. If None, key is integer. |
...
|
|
tuple[Any, Any] | None
|
Value to return if key is missing. |
...
|
|
QueueSideLiteral | QueueSide
|
Either 'back' or 'front'. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value or default if queue is empty. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
apull
async
apull(
*,
prefix: str | None = ...,
default: None,
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any | None]
apull(
*,
prefix: str | None = ...,
default: tuple[Any, _AnyT],
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any | _AnyT]
apull(
*,
prefix: str | None = ...,
default: tuple[Any, Any] | None = ...,
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any]
Async pull key and value item pair from side of queue in cache.
When prefix is None, integer keys are used. Otherwise, string keys are used.
If queue is empty, return default.
Operation is atomic. Concurrent operations will be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | None
|
Key prefix. If None, key is integer. |
...
|
|
tuple[Any, Any] | None
|
Value to return if key is missing. |
...
|
|
QueueSideLiteral | QueueSide
|
Either 'back' or 'front'. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value or default if queue is empty. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
peek
peek(
*,
prefix: str | None = ...,
default: None,
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any | None]
peek(
*,
prefix: str | None = ...,
default: tuple[Any, _AnyT],
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any | _AnyT]
peek(
*,
prefix: str | None = ...,
default: tuple[Any, Any] | None = ...,
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any]
Peek at key and value item pair from side of queue in cache.
When prefix is None, integer keys are used. Otherwise, string keys are used.
If queue is empty, return default.
Expired items are deleted from cache. Operation is atomic. Concurrent operations will be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | None
|
Key prefix. If None, key is integer. |
...
|
|
tuple[Any, Any] | None
|
Value to return if key is missing. |
...
|
|
QueueSideLiteral | QueueSide
|
Either 'back' or 'front'. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value or default if queue is empty. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
apeek
async
apeek(
*,
prefix: str | None = ...,
default: None,
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any | None]
apeek(
*,
prefix: str | None = ...,
default: tuple[Any, _AnyT],
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any | _AnyT]
apeek(
*,
prefix: str | None = ...,
default: tuple[Any, Any] | None = ...,
side: QueueSideLiteral | QueueSide = ...,
retry: bool = ...
) -> Container[Any]
Async peek at key and value item pair from side of queue in cache.
When prefix is None, integer keys are used. Otherwise, string keys are used.
If queue is empty, return default.
Expired items are deleted from cache. Operation is atomic. Concurrent operations will be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | None
|
Key prefix. If None, key is integer. |
...
|
|
tuple[Any, Any] | None
|
Value to return if key is missing. |
...
|
|
QueueSideLiteral | QueueSide
|
Either 'back' or 'front'. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value or default if queue is empty. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
peekitem
Peek at key and value item pair in cache based on iteration order.
Expired items are deleted from cache. Operation is atomic. Concurrent operations will be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Last item in iteration order. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
apeekitem
async
Async peek at key and value item pair in cache based on iteration order.
Expired items are deleted from cache. Operation is atomic. Concurrent operations will be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Last item in iteration order. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
Container[Any]
|
Container with cached value. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
check
Check database and file system consistency.
Intended for use in testing and post-mortem error analysis.
While checking the Cache table for consistency, a writer lock is held on the database. The lock blocks other cache clients from writing to the database. For caches with many file references, the lock may be held for a long time. For example, local benchmarking shows that a cache with 1,000 file references takes ~60ms to check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Correct inconsistencies. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
list[WarningMessage]
|
List of warnings. |
Source code in src/typed_diskcache/interface/cache.py
acheck
async
Async check database and file system consistency.
Intended for use in testing and post-mortem error analysis.
While checking the Cache table for consistency, a writer lock is held on the database. The lock blocks other cache clients from writing to the database. For caches with many file references, the lock may be held for a long time. For example, local benchmarking shows that a cache with 1,000 file references takes ~60ms to check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Correct inconsistencies. |
...
|
|
bool
|
Retry if database timeout occurs. |
...
|
Returns:
| Type | Description |
|---|---|
list[WarningMessage]
|
List of warnings. |
Source code in src/typed_diskcache/interface/cache.py
iterkeys
Iterate Cache keys in database sort order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Reverse sort order. |
...
|
Yields:
| Type | Description |
|---|---|
Any
|
Key of item. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
aiterkeys
aiterkeys(
*, reverse: bool = ...
) -> AsyncGenerator[Any, None]
Async iterate Cache keys in database sort order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Reverse sort order. |
...
|
Yields:
| Type | Description |
|---|---|
AsyncGenerator[Any, None]
|
Key of item. |
Examples:
Source code in src/typed_diskcache/interface/cache.py
update_settings
update_settings(
settings: Settings | SettingsKwargs | None = ...,
**kwargs: Unpack[SettingsKwargs]
) -> None
Update cache settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Settings | SettingsKwargs | None
|
New settings. |
...
|
|
Unpack[SettingsKwargs]
|
Additional settings. |
{}
|
Source code in src/typed_diskcache/interface/cache.py
aupdate_settings
async
aupdate_settings(
settings: Settings | SettingsKwargs | None = ...,
**kwargs: Unpack[SettingsKwargs]
) -> None
Async update cache settings.
Asynchronous version of
update_settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Settings | SettingsKwargs | None
|
New settings. |
...
|
|
Unpack[SettingsKwargs]
|
Additional settings. |
{}
|