<!-- # hard line break macro for HTML -->

# fiftyone.operators.store.store

Execution store class.

Copyright 2017-2026, Voxel51, Inc.
<br/>
[voxel51.com](https://voxel51.com/)
<br/>
<br/>

**Classes:**

| [`ExecutionStore`](#fiftyone.operators.store.store.ExecutionStore)(store_name, store_service[, ...])   | Execution store.   |
|--------------------------------------------------------------------------------------------------------|--------------------|

### *class* fiftyone.operators.store.store.ExecutionStore(store_name: str, store_service: [ExecutionStoreService](fiftyone.operators.store.service.md#fiftyone.operators.store.service.ExecutionStoreService), default_policy: str = 'persist')

Bases: `object`

Execution store.

* **Parameters:**
  * **store_name** – the name of the store
  * **store_service** – an
    [`fiftyone.operators.store.service.ExecutionStoreService`](fiftyone.operators.store.service.md#fiftyone.operators.store.service.ExecutionStoreService)
  * **default_policy** ( *"persist"*) – the default eviction policy for the store.

**Methods:**

| [`create`](#fiftyone.operators.store.store.ExecutionStore.create)(store_name[, dataset_id, ...])                      | Creates a new execution store.                                     |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
| [`list_stores`](#fiftyone.operators.store.store.ExecutionStore.list_stores)()                                         | Lists all stores in the execution store.                           |
| [`get`](#fiftyone.operators.store.store.ExecutionStore.get)(key)                                                      | Retrieves a value from the store by its key.                       |
| [`set`](#fiftyone.operators.store.store.ExecutionStore.set)(key, value[, ttl, policy])                                | Sets the value of a key in the specified store.                    |
| [`set_cache`](#fiftyone.operators.store.store.ExecutionStore.set_cache)(key, value[, ttl])                            | Sets a value in the store with the eviction policy set to "evict". |
| [`set_if_absent`](#fiftyone.operators.store.store.ExecutionStore.set_if_absent)(key, value[, ttl, policy])            | Sets a key only when it does not already exist.                    |
| [`compare_and_set`](#fiftyone.operators.store.store.ExecutionStore.compare_and_set)(key, expected, value[, ttl, ...]) | Atomically replaces a key whose value matches `expected`.          |
| [`delete`](#fiftyone.operators.store.store.ExecutionStore.delete)(key)                                                | Deletes a key from the store.                                      |
| [`has`](#fiftyone.operators.store.store.ExecutionStore.has)(key)                                                      | Checks if the store has a specific key.                            |
| [`clear`](#fiftyone.operators.store.store.ExecutionStore.clear)()                                                     | Clears all the data in the store.                                  |
| [`clear_cache`](#fiftyone.operators.store.store.ExecutionStore.clear_cache)()                                         | Clears the cache for the store.                                    |
| [`update_ttl`](#fiftyone.operators.store.store.ExecutionStore.update_ttl)(key, new_ttl)                               | Updates the TTL for a specific key.                                |
| [`update_policy`](#fiftyone.operators.store.store.ExecutionStore.update_policy)(key, policy)                          | Updates the eviction policy for a specific key.                    |
| [`get_metadata`](#fiftyone.operators.store.store.ExecutionStore.get_metadata)(key)                                    | Retrieves the metadata for the given key.                          |
| [`list_keys`](#fiftyone.operators.store.store.ExecutionStore.list_keys)()                                             | Lists all keys in the store.                                       |
| [`subscribe`](#fiftyone.operators.store.store.ExecutionStore.subscribe)(callback)                                     | Subscribes to changes in the store.                                |
| [`unsubscribe`](#fiftyone.operators.store.store.ExecutionStore.unsubscribe)(subscription_id)                          | Unsubscribes from changes in the store.                            |

#### *static* create(store_name: str, dataset_id: [ObjectId](https://pymongo.readthedocs.io/en/stable/api/bson/objectid.html#bson.objectid.ObjectId) | None = None, default_policy: str = 'persist', collection_name: str | None = None) → [ExecutionStore](#fiftyone.operators.store.store.ExecutionStore)

Creates a new execution store.

* **Parameters:**
  * **store_name** – the name of the store
  * **dataset_id** – an optional dataset ID to scope the store to
* **Returns:**
  an ExecutionStore instance

#### list_stores() → [list](fiftyone.core.session.events.md#fiftyone.core.session.events.Colorscale.list)[str]

Lists all stores in the execution store.

* **Returns:**
  a list of store names
* **Return type:**
  [list](fiftyone.core.session.events.md#fiftyone.core.session.events.Colorscale.list)

#### get(key: str) → Any | None

Retrieves a value from the store by its key.

* **Parameters:**
  **key** – the key to retrieve the value for
* **Returns:**
  the value stored under the given key, or None if not found

#### set(key: str, value: Any, ttl: int | None = None, policy=None) → None

Sets the value of a key in the specified store.

* **Parameters:**
  * **key** – the key to set
  * **value** – the value to set
  * **ttl** (*None*) – an optional TTL in seconds
  * **policy** (*persist*) – the eviction policy for the key. Can be “persist” or “evict”.
    If “persist”, the key will never be automatically removed.
    If “evict”, the key may be removed automatically if a TTL is set,
    or manually via [`clear_cache()`](#fiftyone.operators.store.store.ExecutionStore.clear_cache).
* **Returns:**
  a `fiftyone.store.models.KeyDocument`

#### set_cache(key: str, value: Any, ttl: int | None = None) → None

Sets a value in the store with the eviction policy set to “evict”.

* **Parameters:**
  * **key** – the key to store the value under
  * **value** – the value to store
  * **ttl** (*None*) – the time-to-live in seconds

#### set_if_absent(key: str, value: Any, ttl: int | None = None, policy=None) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Sets a key only when it does not already exist.

#### compare_and_set(key: str, expected: Any, value: Any, ttl: int | None = None, policy=None) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Atomically replaces a key whose value matches `expected`.

Existing expiration and policy metadata is preserved when `ttl` and
`policy` are omitted.

#### delete(key: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Deletes a key from the store.

* **Parameters:**
  **key** – the key to delete.
* **Returns:**
  True/False whether the key was deleted

#### has(key: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Checks if the store has a specific key.

* **Parameters:**
  **key** – the key to check
* **Returns:**
  True/False whether the key exists

#### clear() → None

Clears all the data in the store.

#### clear_cache() → None

Clears the cache for the store.

This will remove all keys that are eligible for eviction.

#### update_ttl(key: str, new_ttl: int) → None

Updates the TTL for a specific key.

* **Parameters:**
  * **key** – the key to update the TTL for
  * **new_ttl** – the new TTL in seconds

#### update_policy(key: str, policy: str) → None

Updates the eviction policy for a specific key.

* **Parameters:**
  * **key** – the key to update the policy for
  * **policy** – the new policy, either “persist” or “evict”

#### get_metadata(key: str) → dict | None

Retrieves the metadata for the given key.

* **Parameters:**
  **key** – the key to check
* **Returns:**
  a dict of metadata about the key

#### list_keys() → [list](fiftyone.core.session.events.md#fiftyone.core.session.events.Colorscale.list)[str]

Lists all keys in the store.

* **Returns:**
  a list of keys in the store

#### subscribe(callback: Callable[[[MessageData](fiftyone.operators.message.md#fiftyone.operators.message.MessageData)], None]) → str

Subscribes to changes in the store.

* **Parameters:**
  **callback** – a function that will be called when a change occurs in the store
* **Returns:**
  a subscription ID

#### unsubscribe(subscription_id: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Unsubscribes from changes in the store.

* **Parameters:**
  **subscription_id** – the subscription ID to unsubscribe from
* **Returns:**
  True if the subscription was removed, False otherwise
