tensorstore.KvStore.__setitem__(self, key: str, value: str | None)

Synchronously writes the value of a single key.

Example

>>> store = ts.KvStore.open({'driver': 'memory'}).result()
>>> store[b'a'] = b'value'
>>> store[b'a']
b'value'
>>> store[b'b']
Traceback (most recent call last):
    ...
KeyError...
>>> store[b'a'] = None
>>> store[b'a']
Traceback (most recent call last):
    ...
KeyError...
Parameters:
key: str

Key to write/delete. This is appended (without any separator) to the existing path, if any.

value: str | None

Value to store, or None to delete.

Raises:

Exception – If an I/O error occurs.

Note

  • If no transaction is specified, the current thread is blocked until the write completes and durability is guaranteed (to the extent supported by the driver).

  • If a transaction is specified, the current thread is blocked until the write is recorded in the transaction. The actual write operation is not performed until the transaction is committed.

Computations in other threads may continue even while the current thread is blocked.