static tensorstore.KvStore.open(spec: KvStore.Spec | Any, *, context: Context | None = None, transaction: Transaction | None = None) Future[KvStore]

Opens a key-value store.

Example of opening from a JSON KvStore spec:

>>> kvstore = await ts.KvStore.open({'driver': 'memory', 'path': 'abc/'})
>>> await kvstore.write(b'x', b'y')
KvStore.TimestampedStorageGeneration(b'...', ...)
>>> await kvstore.read(b'x')
KvStore.ReadResult(state='value', value=b'y', stamp=KvStore.TimestampedStorageGeneration(b'...', ...))

Example of opening from a URL:

>>> kvstore = await ts.KvStore.open('memory://abc/')
>>> kvstore.spec()
KvStore.Spec({'driver': 'memory', 'path': 'abc/'})

Example of opening from an existing KvStore.Spec:

>>> spec = ts.KvStore.Spec({'driver': 'memory', 'path': 'abc/'})
>>> kvstore = await ts.KvStore.open(spec)
>>> kvstore.spec()
KvStore.Spec({'driver': 'memory', 'path': 'abc/'})
Parameters:
spec: KvStore.Spec | Any

Key-value store spec to open. May also be specified as JSON or a URL.

context: Context | None = None

Bind any context resource specs using the specified shared resource context.

Any already-bound context resources remain unchanged. Additionally, any context resources specified by a nested KvStore.context spec will be created as specified, but won’t be overridden by context.

transaction: Transaction | None = None

Transaction to use for read/write operations. By default, operations are non-transactional.

Note

To perform transactional operations using a KvStore that was previously opened without a transaction, use KvStore.with_transaction.