TransactionalCacheLike
Usage
TransactionalCacheLike()Cache and NullCache both have and FanoutCache doesn’t.
On a Cache, with cache.transact() as tx: runs the block’s calls on this thread in one write transaction; tx is the cache. On a NullCache it’s a no-op that yields the NullCache.
Examples
from diskcache_oxide import TransactionalCacheLike
def count(cache: TransactionalCacheLike, path: str) -> None:
with cache.transact() as tx:
tx.incr('requests')
tx.incr(f'requests:{path}')Methods
| Name | Description |
|---|---|
| peek() |
(key, value) at a queue’s end, or default, without removing it.
|
| peekitem() |
The newest (or oldest) (key, value) of any key, without removing it.
|
| pull() |
Remove and return (key, value) from a queue, or default.
|
| push() |
Push value onto a queue and return its key (None on a durable outage).
|
| transact() | A context manager holding a write transaction for the block, yielding the cache. |
peek()
(key, value) at a queue’s end, or default, without removing it.
Usage
peek(
prefix=None,
default=(None, None),
side="front",
*,
expire_time=False,
tag=False,
retry=False
)peekitem()
The newest (or oldest) (key, value) of any key, without removing it.
Usage
peekitem(last=True, *, expire_time=False, tag=False, retry=False)pull()
Remove and return (key, value) from a queue, or default.
Usage
pull(
prefix=None,
default=(None, None),
side="front",
*,
expire_time=False,
tag=False,
retry=False
)push()
Push value onto a queue and return its key (None on a durable outage).
Usage
push(self, value: Any, prefix: None = None, side: Literal['front', 'back'] = 'back', expire: Optional[float] = None, tag: Key = None, retry: bool = False) -> Optional[int]
push(self, value: Any, prefix: str, side: Literal['front', 'back'] = 'back', expire: Optional[float] = None, tag: Key = None, retry: bool = False) -> Optional[str]
push(self, value: Any, prefix: Optional[str] = None, side: Literal['front', 'back'] = 'back', expire: Optional[float] = None, tag: Key = None, retry: bool = False) -> Optional[int | str]transact()
A context manager holding a write transaction for the block, yielding the cache.
Usage
transact(retry=False)