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

# fiftyone.factory.repos.execution_store

Execution store repository interface and implementations.

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

**Classes:**

| [`AbstractExecutionStoreRepo`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo)()                  | Abstract base class for execution store repositories.     |
|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [`ExecutionStoreRepo`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo)([dataset_id, ...])                 | Base class for execution store repositories.              |
| [`MongoExecutionStoreRepo`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo)(collection[, ...])       | MongoDB implementation of the execution store repository. |
| [`InMemoryExecutionStoreRepo`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo)([dataset_id, ...]) | In-memory implementation of execution store repository.   |

### *class* fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo

Bases: `ABC`

Abstract base class for execution store repositories.

**Methods:**

| [`create_store`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.create_store)(store_name[, metadata, policy])            | Create a store in the store collection.                    |
|----------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [`get_store`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.get_store)(store_name)                                      | Get a store from the store collection.                     |
| [`has_store`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.has_store)(store_name)                                      | Check if a store exists in the store collection.           |
| [`list_stores`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.list_stores)()                                            | List all stores in the store collection.                   |
| [`count_stores`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.count_stores)()                                          | Count the number of stores in the store collection.        |
| [`delete_store`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.delete_store)(store_name)                                | Delete a store.                                            |
| [`set_key`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.set_key)(store_name, key, value[, ttl, policy])               | Set a key in a store.                                      |
| [`set_cache_key`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.set_cache_key)(store_name, key, value[, ttl])           | Set a cache key in a store.                                |
| [`set_key_if_absent`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.set_key_if_absent)(store_name, key, value[, ...])   | Sets a key only when it does not already exist.            |
| [`compare_and_set_key`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.compare_and_set_key)(store_name, key, ...[, ...]) | Atomically replaces a key whose value matches `expected`.  |
| [`has_key`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.has_key)(store_name, key)                                     | Check if a key exists in a store.                          |
| [`get_key`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.get_key)(store_name, key)                                     | Get a key from a store.                                    |
| [`update_ttl`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.update_ttl)(store_name, key, ttl)                          | Update the TTL of a key.                                   |
| [`delete_key`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.delete_key)(store_name, key)                               | Delete a key from a store.                                 |
| [`list_keys`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.list_keys)(store_name)                                      | List all keys in a store.                                  |
| [`count_keys`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.count_keys)(store_name)                                    | Count the number of keys in a store.                       |
| [`cleanup`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.cleanup)()                                                    | Delete all stores in the global store collection.          |
| [`clear_cache`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.clear_cache)([store_name])                                | Clear all keys with either a `ttl` or `policy="evict"`.    |
| [`has_store_global`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.has_store_global)(store_name)                        | Check if a store exists in the global store collection.    |
| [`list_stores_global`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.list_stores_global)()                              | List all stores in the global store collection.            |
| [`count_stores_global`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.count_stores_global)()                            | Count the number of stores in the global store collection. |
| [`delete_store_global`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo.delete_store_global)(store_name)                  | Delete a store from the global store collection.           |

#### *abstractmethod* create_store(store_name: str, metadata: Dict[str, Any] | None = None, policy: str = 'persist') → [StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument)

Create a store in the store collection.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to create
  * **metadata** (*Optional* *[**Dict* *[**str* *,* *Any* *]* *]*) – the metadata to store with the store
* **Returns:**
  the created store document
* **Return type:**
  [StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)

#### *abstractmethod* get_store(store_name: str) → [StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument) | None

Get a store from the store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to get
* **Returns:**
  the store document, or None if the store does not exist
* **Return type:**
  Optional[[StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)]

#### *abstractmethod* has_store(store_name: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a store exists in the store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to check
* **Returns:**
  True if the store exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* list_stores() → List[str]

List all stores in the store collection.

* **Returns:**
  a list of store names
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[str]

#### *abstractmethod* count_stores() → int

Count the number of stores in the store collection.

* **Returns:**
  the number of stores
* **Return type:**
  int

#### *abstractmethod* delete_store(store_name: str) → int

Delete a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to delete
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### *abstractmethod* set_key(store_name: str, key: str, value: Any, ttl: int | None = None, policy: str = 'persist') → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument)

Set a key in a store.

* **Parameters:**
  * **store_name** (*str*) – The name of the store to set the key in.
  * **key** (*str*) – The key to set.
  * **value** (*Any*) – The value to associate with the key.
  * **ttl** (*Optional* *[**int* *]*) – Optional TTL (in seconds) after which the key
    will expire and be automatically removed.
  * **policy** (*str*) – The eviction policy for the key. One of:
    - `"persist"` (default): Key is persistent until deleted.
    - `"evict"`: Key is eligible for eviction or cache clearing.
* **Returns:**
  The created or updated key document.
* **Return type:**
  [KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)

#### *abstractmethod* set_cache_key(store_name: str, key: str, value: Any, ttl: int | None = None) → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument)

Set a cache key in a store.
:param store_name: the name of the store to set the cache key in
:type store_name: str
:param key: the cache key to set
:type key: str
:param value: the value to set
:type value: Any
:param ttl: the TTL of the cache key
:type ttl: Optional[int]

* **Returns:**
  the created or updated cache key document
* **Return type:**
  [KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)

#### *abstractmethod* set_key_if_absent(store_name: str, key: str, value: Any, ttl: int | None = None, policy: str = 'persist') → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Sets a key only when it does not already exist.

#### *abstractmethod* compare_and_set_key(store_name: str, key: str, expected: Any, value: Any, ttl: int | None = None, policy: str | None = 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.

#### *abstractmethod* has_key(store_name: str, key: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a key exists in a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to check
  * **key** (*str*) – the key to check
* **Returns:**
  True if the key exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* get_key(store_name: str, key: str) → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument) | None

Get a key from a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to get the key from
  * **key** (*str*) – the key to get
* **Returns:**
  the key document, or None if the key does not exist
* **Return type:**
  Optional[[KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)]

#### *abstractmethod* update_ttl(store_name: str, key: str, ttl: int) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Update the TTL of a key.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to update the TTL for
  * **key** (*str*) – the key to update the TTL for
  * **ttl** (*int*) – the new TTL
* **Returns:**
  True if the TTL was updated, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* delete_key(store_name: str, key: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Delete a key from a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to delete the key from
  * **key** (*str*) – the key to delete
* **Returns:**
  True if the key was deleted, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* list_keys(store_name: str) → List[str]

List all keys in a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to list keys for
* **Returns:**
  a list of keys in the store
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[str]

#### *abstractmethod* count_keys(store_name: str) → int

Count the number of keys in a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to count keys for
* **Returns:**
  the number of keys in the store
* **Return type:**
  int

#### *abstractmethod* cleanup() → int

Delete all stores in the global store collection.

* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### *abstractmethod* clear_cache(store_name: str | None = None) → int

Clear all keys with either a `ttl` or `policy="evict"`.

* **Parameters:**
  **store_name** (*Optional* *[**str* *]*) – the name of the store to clear. If None,
  all stores will be queried for deletion.
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### *abstractmethod* has_store_global(store_name: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a store exists in the global store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to check
* **Returns:**
  True if the store exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* list_stores_global() → List[[StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument)]

List all stores in the global store collection.

* **Returns:**
  a list of store documents
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[[StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)]

#### *abstractmethod* count_stores_global() → int

Count the number of stores in the global store collection.

* **Returns:**
  the number of stores
* **Return type:**
  int

#### *abstractmethod* delete_store_global(store_name: str) → int

Delete a store from the global store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to delete
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

### *class* fiftyone.factory.repos.execution_store.ExecutionStoreRepo(dataset_id: [ObjectId](https://pymongo.readthedocs.io/en/stable/api/bson/objectid.html#bson.objectid.ObjectId) | None = None, notification_service: [ChangeStreamNotificationService](fiftyone.operators.store.notification_service.md#fiftyone.operators.store.notification_service.ChangeStreamNotificationService) | None = None)

Bases: [`AbstractExecutionStoreRepo`](#fiftyone.factory.repos.execution_store.AbstractExecutionStoreRepo)

Base class for execution store repositories.

Each instance operates in a context:
- If a `dataset_id` is provided, it operates on stores associated with that dataset.
- If no `dataset_id` is provided, it operates on stores not associated with any dataset.

To operate on all stores across all contexts, use the `XXX_global()`
methods that this class provides.

**Methods:**

| [`subscribe`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.subscribe)(store_name, callback)                            | Subscribe to changes in a store.                           |
|--------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [`unsubscribe`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.unsubscribe)(subscription_id)                             | Unsubscribe from changes in a store.                       |
| [`cleanup`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.cleanup)()                                                    | Delete all stores in the global store collection.          |
| [`clear_cache`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.clear_cache)([store_name])                                | Clear all keys with either a `ttl` or `policy="evict"`.    |
| [`compare_and_set_key`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.compare_and_set_key)(store_name, key, ...[, ...]) | Atomically replaces a key whose value matches `expected`.  |
| [`count_keys`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.count_keys)(store_name)                                    | Count the number of keys in a store.                       |
| [`count_stores`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.count_stores)()                                          | Count the number of stores in the store collection.        |
| [`count_stores_global`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.count_stores_global)()                            | Count the number of stores in the global store collection. |
| [`create_store`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.create_store)(store_name[, metadata, policy])            | Create a store in the store collection.                    |
| [`delete_key`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.delete_key)(store_name, key)                               | Delete a key from a store.                                 |
| [`delete_store`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.delete_store)(store_name)                                | Delete a store.                                            |
| [`delete_store_global`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.delete_store_global)(store_name)                  | Delete a store from the global store collection.           |
| [`get_key`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.get_key)(store_name, key)                                     | Get a key from a store.                                    |
| [`get_store`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.get_store)(store_name)                                      | Get a store from the store collection.                     |
| [`has_key`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.has_key)(store_name, key)                                     | Check if a key exists in a store.                          |
| [`has_store`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.has_store)(store_name)                                      | Check if a store exists in the store collection.           |
| [`has_store_global`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.has_store_global)(store_name)                        | Check if a store exists in the global store collection.    |
| [`list_keys`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.list_keys)(store_name)                                      | List all keys in a store.                                  |
| [`list_stores`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.list_stores)()                                            | List all stores in the store collection.                   |
| [`list_stores_global`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.list_stores_global)()                              | List all stores in the global store collection.            |
| [`set_cache_key`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.set_cache_key)(store_name, key, value[, ttl])           | Set a cache key in a store.                                |
| [`set_key`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.set_key)(store_name, key, value[, ttl, policy])               | Set a key in a store.                                      |
| [`set_key_if_absent`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.set_key_if_absent)(store_name, key, value[, ...])   | Sets a key only when it does not already exist.            |
| [`update_ttl`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo.update_ttl)(store_name, key, ttl)                          | Update the TTL of a key.                                   |

#### subscribe(store_name: str, callback: Callable[[str], None]) → str

Subscribe to changes in a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to subscribe to
  * **callback** (*Callable* *[* *[**str* *]* *,* *None* *]*) – the callback to call when a change occurs
* **Returns:**
  the subscription ID
* **Return type:**
  str
* **Raises:**
  **ValueError** – if no notification service is available

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

Unsubscribe from changes in a store.

* **Parameters:**
  **subscription_id** (*str*) – the subscription ID to unsubscribe
* **Returns:**
  True if the subscription was removed, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)
* **Raises:**
  **ValueError** – if no notification service is available

#### *abstractmethod* cleanup() → int

Delete all stores in the global store collection.

* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### *abstractmethod* clear_cache(store_name: str | None = None) → int

Clear all keys with either a `ttl` or `policy="evict"`.

* **Parameters:**
  **store_name** (*Optional* *[**str* *]*) – the name of the store to clear. If None,
  all stores will be queried for deletion.
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### *abstractmethod* compare_and_set_key(store_name: str, key: str, expected: Any, value: Any, ttl: int | None = None, policy: str | None = 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.

#### *abstractmethod* count_keys(store_name: str) → int

Count the number of keys in a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to count keys for
* **Returns:**
  the number of keys in the store
* **Return type:**
  int

#### *abstractmethod* count_stores() → int

Count the number of stores in the store collection.

* **Returns:**
  the number of stores
* **Return type:**
  int

#### *abstractmethod* count_stores_global() → int

Count the number of stores in the global store collection.

* **Returns:**
  the number of stores
* **Return type:**
  int

#### *abstractmethod* create_store(store_name: str, metadata: Dict[str, Any] | None = None, policy: str = 'persist') → [StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument)

Create a store in the store collection.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to create
  * **metadata** (*Optional* *[**Dict* *[**str* *,* *Any* *]* *]*) – the metadata to store with the store
* **Returns:**
  the created store document
* **Return type:**
  [StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)

#### *abstractmethod* delete_key(store_name: str, key: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Delete a key from a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to delete the key from
  * **key** (*str*) – the key to delete
* **Returns:**
  True if the key was deleted, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* delete_store(store_name: str) → int

Delete a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to delete
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### *abstractmethod* delete_store_global(store_name: str) → int

Delete a store from the global store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to delete
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### *abstractmethod* get_key(store_name: str, key: str) → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument) | None

Get a key from a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to get the key from
  * **key** (*str*) – the key to get
* **Returns:**
  the key document, or None if the key does not exist
* **Return type:**
  Optional[[KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)]

#### *abstractmethod* get_store(store_name: str) → [StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument) | None

Get a store from the store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to get
* **Returns:**
  the store document, or None if the store does not exist
* **Return type:**
  Optional[[StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)]

#### *abstractmethod* has_key(store_name: str, key: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a key exists in a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to check
  * **key** (*str*) – the key to check
* **Returns:**
  True if the key exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* has_store(store_name: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a store exists in the store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to check
* **Returns:**
  True if the store exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* has_store_global(store_name: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a store exists in the global store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to check
* **Returns:**
  True if the store exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### *abstractmethod* list_keys(store_name: str) → List[str]

List all keys in a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to list keys for
* **Returns:**
  a list of keys in the store
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[str]

#### *abstractmethod* list_stores() → List[str]

List all stores in the store collection.

* **Returns:**
  a list of store names
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[str]

#### *abstractmethod* list_stores_global() → List[[StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument)]

List all stores in the global store collection.

* **Returns:**
  a list of store documents
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[[StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)]

#### *abstractmethod* set_cache_key(store_name: str, key: str, value: Any, ttl: int | None = None) → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument)

Set a cache key in a store.
:param store_name: the name of the store to set the cache key in
:type store_name: str
:param key: the cache key to set
:type key: str
:param value: the value to set
:type value: Any
:param ttl: the TTL of the cache key
:type ttl: Optional[int]

* **Returns:**
  the created or updated cache key document
* **Return type:**
  [KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)

#### *abstractmethod* set_key(store_name: str, key: str, value: Any, ttl: int | None = None, policy: str = 'persist') → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument)

Set a key in a store.

* **Parameters:**
  * **store_name** (*str*) – The name of the store to set the key in.
  * **key** (*str*) – The key to set.
  * **value** (*Any*) – The value to associate with the key.
  * **ttl** (*Optional* *[**int* *]*) – Optional TTL (in seconds) after which the key
    will expire and be automatically removed.
  * **policy** (*str*) – The eviction policy for the key. One of:
    - `"persist"` (default): Key is persistent until deleted.
    - `"evict"`: Key is eligible for eviction or cache clearing.
* **Returns:**
  The created or updated key document.
* **Return type:**
  [KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)

#### *abstractmethod* set_key_if_absent(store_name: str, key: str, value: Any, ttl: int | None = None, policy: str = 'persist') → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Sets a key only when it does not already exist.

#### *abstractmethod* update_ttl(store_name: str, key: str, ttl: int) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Update the TTL of a key.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to update the TTL for
  * **key** (*str*) – the key to update the TTL for
  * **ttl** (*int*) – the new TTL
* **Returns:**
  True if the TTL was updated, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

### *class* fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo(collection, dataset_id: [ObjectId](https://pymongo.readthedocs.io/en/stable/api/bson/objectid.html#bson.objectid.ObjectId) | None = None, notification_service: [ChangeStreamNotificationService](fiftyone.operators.store.notification_service.md#fiftyone.operators.store.notification_service.ChangeStreamNotificationService) | None = None)

Bases: [`ExecutionStoreRepo`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo)

MongoDB implementation of the execution store repository.

**Attributes:**

| [`COLLECTION_NAME`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.COLLECTION_NAME)   |    |
|--------------------------------------------------------------------------------------------------------|----|

**Methods:**

| [`create_store`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.create_store)(store_name[, metadata, policy])            | Create a store in the store collection.                    |
|-------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [`clear_cache`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.clear_cache)([store_name])                                | Clear all keys with either a `ttl` or `policy="evict"`.    |
| [`get_store`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.get_store)(store_name)                                      | Get a store from the store collection.                     |
| [`has_store`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.has_store)(store_name)                                      | Check if a store exists in the store collection.           |
| [`list_stores`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.list_stores)()                                            | List all stores in the store collection.                   |
| [`count_stores`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.count_stores)()                                          | Count the number of stores in the store collection.        |
| [`delete_store`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.delete_store)(store_name)                                | Delete a store.                                            |
| [`set_key`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.set_key)(store_name, key, value[, ttl, policy])               | Set a key in a store.                                      |
| [`set_cache_key`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.set_cache_key)(store_name, key, value[, ttl])           | Set a cache key in a store.                                |
| [`set_key_if_absent`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.set_key_if_absent)(store_name, key, value[, ...])   | Sets a key only when it does not already exist.            |
| [`compare_and_set_key`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.compare_and_set_key)(store_name, key, ...[, ...]) | Atomically replaces a key whose value matches `expected`.  |
| [`has_key`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.has_key)(store_name, key)                                     | Check if a key exists in a store.                          |
| [`get_key`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.get_key)(store_name, key)                                     | Get a key from a store.                                    |
| [`update_ttl`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.update_ttl)(store_name, key, ttl)                          | Update the TTL of a key.                                   |
| [`delete_key`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.delete_key)(store_name, key)                               | Delete a key from a store.                                 |
| [`list_keys`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.list_keys)(store_name)                                      | List all keys in a store.                                  |
| [`count_keys`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.count_keys)(store_name)                                    | Count the number of keys in a store.                       |
| [`cleanup`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.cleanup)()                                                    | Delete all stores in the global store collection.          |
| [`has_store_global`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.has_store_global)(store_name)                        | Check if a store exists in the global store collection.    |
| [`list_stores_global`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.list_stores_global)()                              | List all stores in the global store collection.            |
| [`count_stores_global`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.count_stores_global)()                            | Count the number of stores in the global store collection. |
| [`delete_store_global`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.delete_store_global)(store_name)                  | Delete a store from the global store collection.           |
| [`subscribe`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.subscribe)(store_name, callback)                            | Subscribe to changes in a store.                           |
| [`unsubscribe`](#fiftyone.factory.repos.execution_store.MongoExecutionStoreRepo.unsubscribe)(subscription_id)                             | Unsubscribe from changes in a store.                       |

#### COLLECTION_NAME *= 'execution_store'*

#### create_store(store_name: str, metadata: Dict[str, Any] | None = None, policy: str = 'persist') → [StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument)

Create a store in the store collection.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to create
  * **metadata** (*Optional* *[**Dict* *[**str* *,* *Any* *]* *]*) – the metadata to store with the store
* **Returns:**
  the created store document
* **Return type:**
  [StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)

#### clear_cache(store_name=None) → int

Clear all keys with either a `ttl` or `policy="evict"`.

* **Parameters:**
  **store_name** (*Optional* *[**str* *]*) – the name of the store to clear. If None,
  all stores will be queried for deletion.
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### get_store(store_name: str) → [StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument) | None

Get a store from the store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to get
* **Returns:**
  the store document, or None if the store does not exist
* **Return type:**
  Optional[[StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)]

#### has_store(store_name: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a store exists in the store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to check
* **Returns:**
  True if the store exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### list_stores() → List[str]

List all stores in the store collection.

* **Returns:**
  a list of store names
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[str]

#### count_stores() → int

Count the number of stores in the store collection.

* **Returns:**
  the number of stores
* **Return type:**
  int

#### delete_store(store_name: str) → int

Delete a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to delete
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### set_key(store_name: str, key: str, value: Any, ttl: int | None = None, policy: str = 'persist') → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument)

Set a key in a store.

* **Parameters:**
  * **store_name** (*str*) – The name of the store to set the key in.
  * **key** (*str*) – The key to set.
  * **value** (*Any*) – The value to associate with the key.
  * **ttl** (*Optional* *[**int* *]*) – Optional TTL (in seconds) after which the key
    will expire and be automatically removed.
  * **policy** (*str*) – The eviction policy for the key. One of:
    - `"persist"` (default): Key is persistent until deleted.
    - `"evict"`: Key is eligible for eviction or cache clearing.
* **Returns:**
  The created or updated key document.
* **Return type:**
  [KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)

#### set_cache_key(store_name, key, value, ttl=None)

Set a cache key in a store.
:param store_name: the name of the store to set the cache key in
:type store_name: str
:param key: the cache key to set
:type key: str
:param value: the value to set
:type value: Any
:param ttl: the TTL of the cache key
:type ttl: Optional[int]

* **Returns:**
  the created or updated cache key document
* **Return type:**
  [KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)

#### set_key_if_absent(store_name, key, value, ttl=None, policy='persist')

Sets a key only when it does not already exist.

#### compare_and_set_key(store_name, key, expected, value, ttl=None, policy=None)

Atomically replaces a key whose value matches `expected`.

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

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

Check if a key exists in a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to check
  * **key** (*str*) – the key to check
* **Returns:**
  True if the key exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### get_key(store_name: str, key: str) → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument) | None

Get a key from a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to get the key from
  * **key** (*str*) – the key to get
* **Returns:**
  the key document, or None if the key does not exist
* **Return type:**
  Optional[[KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)]

#### update_ttl(store_name: str, key: str, ttl: int) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Update the TTL of a key.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to update the TTL for
  * **key** (*str*) – the key to update the TTL for
  * **ttl** (*int*) – the new TTL
* **Returns:**
  True if the TTL was updated, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

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

Delete a key from a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to delete the key from
  * **key** (*str*) – the key to delete
* **Returns:**
  True if the key was deleted, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### list_keys(store_name: str) → List[str]

List all keys in a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to list keys for
* **Returns:**
  a list of keys in the store
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[str]

#### count_keys(store_name: str) → int

Count the number of keys in a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to count keys for
* **Returns:**
  the number of keys in the store
* **Return type:**
  int

#### cleanup() → int

Delete all stores in the global store collection.

* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### has_store_global(store_name: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a store exists in the global store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to check
* **Returns:**
  True if the store exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### list_stores_global() → List[[StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument)]

List all stores in the global store collection.

* **Returns:**
  a list of store documents
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[[StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)]

#### count_stores_global() → int

Count the number of stores in the global store collection.

* **Returns:**
  the number of stores
* **Return type:**
  int

#### delete_store_global(store_name: str) → int

Delete a store from the global store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to delete
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### subscribe(store_name: str, callback: Callable[[str], None]) → str

Subscribe to changes in a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to subscribe to
  * **callback** (*Callable* *[* *[**str* *]* *,* *None* *]*) – the callback to call when a change occurs
* **Returns:**
  the subscription ID
* **Return type:**
  str
* **Raises:**
  **ValueError** – if no notification service is available

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

Unsubscribe from changes in a store.

* **Parameters:**
  **subscription_id** (*str*) – the subscription ID to unsubscribe
* **Returns:**
  True if the subscription was removed, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)
* **Raises:**
  **ValueError** – if no notification service is available

### *class* fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo(dataset_id: [ObjectId](https://pymongo.readthedocs.io/en/stable/api/bson/objectid.html#bson.objectid.ObjectId) | None = None, notification_service: [ChangeStreamNotificationService](fiftyone.operators.store.notification_service.md#fiftyone.operators.store.notification_service.ChangeStreamNotificationService) | None = None)

Bases: [`ExecutionStoreRepo`](#fiftyone.factory.repos.execution_store.ExecutionStoreRepo)

In-memory implementation of execution store repository.

**Methods:**

| [`create_store`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.create_store)(store_name[, metadata, policy])            | Create a store in the store collection.                    |
|----------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [`clear_cache`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.clear_cache)([store_name])                                | Clear all keys with either a `ttl` or `policy="evict"`.    |
| [`get_store`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.get_store)(store_name)                                      | Get a store from the store collection.                     |
| [`has_store`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.has_store)(store_name)                                      | Check if a store exists in the store collection.           |
| [`list_stores`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.list_stores)()                                            | List all stores in the store collection.                   |
| [`count_stores`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.count_stores)()                                          | Count the number of stores in the store collection.        |
| [`delete_store`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.delete_store)(store_name)                                | Delete a store.                                            |
| [`set_key`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.set_key)(store_name, key, value[, ttl, policy])               | Set a key in a store.                                      |
| [`set_cache_key`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.set_cache_key)(store_name, key, value[, ttl])           | Set a cache key in a store.                                |
| [`set_key_if_absent`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.set_key_if_absent)(store_name, key, value[, ...])   | Sets a key only when it does not already exist.            |
| [`compare_and_set_key`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.compare_and_set_key)(store_name, key, ...[, ...]) | Atomically replaces a key whose value matches `expected`.  |
| [`has_key`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.has_key)(store_name, key)                                     | Check if a key exists in a store.                          |
| [`get_key`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.get_key)(store_name, key)                                     | Get a key from a store.                                    |
| [`update_ttl`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.update_ttl)(store_name, key, ttl)                          | Update the TTL of a key.                                   |
| [`update_policy`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.update_policy)(store_name, key, policy)                 |                                                            |
| [`delete_key`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.delete_key)(store_name, key)                               | Delete a key from a store.                                 |
| [`list_keys`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.list_keys)(store_name)                                      | List all keys in a store.                                  |
| [`count_keys`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.count_keys)(store_name)                                    | Count the number of keys in a store.                       |
| [`cleanup`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.cleanup)()                                                    | Delete all stores in the global store collection.          |
| [`has_store_global`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.has_store_global)(store_name)                        | Check if a store exists in the global store collection.    |
| [`list_stores_global`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.list_stores_global)()                              | List all stores in the global store collection.            |
| [`count_stores_global`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.count_stores_global)()                            | Count the number of stores in the global store collection. |
| [`delete_store_global`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.delete_store_global)(store_name)                  | Delete a store from the global store collection.           |
| [`subscribe`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.subscribe)(store_name, callback)                            | Subscribe to changes in a store.                           |
| [`unsubscribe`](#fiftyone.factory.repos.execution_store.InMemoryExecutionStoreRepo.unsubscribe)(subscription_id)                             | Unsubscribe from changes in a store.                       |

#### create_store(store_name: str, metadata: Dict[str, Any] | None = None, policy: str = 'persist') → [StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument)

Create a store in the store collection.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to create
  * **metadata** (*Optional* *[**Dict* *[**str* *,* *Any* *]* *]*) – the metadata to store with the store
* **Returns:**
  the created store document
* **Return type:**
  [StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)

#### clear_cache(store_name=None) → int

Clear all keys with either a `ttl` or `policy="evict"`.

* **Parameters:**
  **store_name** (*Optional* *[**str* *]*) – the name of the store to clear. If None,
  all stores will be queried for deletion.
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### get_store(store_name: str) → [StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument) | None

Get a store from the store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to get
* **Returns:**
  the store document, or None if the store does not exist
* **Return type:**
  Optional[[StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)]

#### has_store(store_name: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a store exists in the store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to check
* **Returns:**
  True if the store exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### list_stores() → List[str]

List all stores in the store collection.

* **Returns:**
  a list of store names
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[str]

#### count_stores() → int

Count the number of stores in the store collection.

* **Returns:**
  the number of stores
* **Return type:**
  int

#### delete_store(store_name: str) → int

Delete a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to delete
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### set_key(store_name: str, key: str, value: Any, ttl: int | None = None, policy: str = 'persist') → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument)

Set a key in a store.

* **Parameters:**
  * **store_name** (*str*) – The name of the store to set the key in.
  * **key** (*str*) – The key to set.
  * **value** (*Any*) – The value to associate with the key.
  * **ttl** (*Optional* *[**int* *]*) – Optional TTL (in seconds) after which the key
    will expire and be automatically removed.
  * **policy** (*str*) – The eviction policy for the key. One of:
    - `"persist"` (default): Key is persistent until deleted.
    - `"evict"`: Key is eligible for eviction or cache clearing.
* **Returns:**
  The created or updated key document.
* **Return type:**
  [KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)

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

Set a cache key in a store.
:param store_name: the name of the store to set the cache key in
:type store_name: str
:param key: the cache key to set
:type key: str
:param value: the value to set
:type value: Any
:param ttl: the TTL of the cache key
:type ttl: Optional[int]

* **Returns:**
  the created or updated cache key document
* **Return type:**
  [KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)

#### set_key_if_absent(store_name, key, value, ttl=None, policy='persist')

Sets a key only when it does not already exist.

#### compare_and_set_key(store_name, key, expected, value, ttl=None, policy=None)

Atomically replaces a key whose value matches `expected`.

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

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

Check if a key exists in a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to check
  * **key** (*str*) – the key to check
* **Returns:**
  True if the key exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### get_key(store_name: str, key: str) → [KeyDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.KeyDocument) | None

Get a key from a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to get the key from
  * **key** (*str*) – the key to get
* **Returns:**
  the key document, or None if the key does not exist
* **Return type:**
  Optional[[KeyDocument](fiftyone.operators.store.md#fiftyone.operators.store.KeyDocument)]

#### update_ttl(store_name: str, key: str, ttl: int) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Update the TTL of a key.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to update the TTL for
  * **key** (*str*) – the key to update the TTL for
  * **ttl** (*int*) – the new TTL
* **Returns:**
  True if the TTL was updated, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### update_policy(store_name: str, key: str, policy: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

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

Delete a key from a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to delete the key from
  * **key** (*str*) – the key to delete
* **Returns:**
  True if the key was deleted, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### list_keys(store_name: str) → List[str]

List all keys in a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to list keys for
* **Returns:**
  a list of keys in the store
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[str]

#### count_keys(store_name: str) → int

Count the number of keys in a store.

* **Parameters:**
  **store_name** (*str*) – the name of the store to count keys for
* **Returns:**
  the number of keys in the store
* **Return type:**
  int

#### cleanup() → int

Delete all stores in the global store collection.

* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### has_store_global(store_name: str) → [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

Check if a store exists in the global store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to check
* **Returns:**
  True if the store exists, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)

#### list_stores_global() → List[[StoreDocument](fiftyone.operators.store.models.md#fiftyone.operators.store.models.StoreDocument)]

List all stores in the global store collection.

* **Returns:**
  a list of store documents
* **Return type:**
  [List](fiftyone.operators.types.md#fiftyone.operators.types.List)[[StoreDocument](fiftyone.operators.store.md#fiftyone.operators.store.StoreDocument)]

#### count_stores_global() → int

Count the number of stores in the global store collection.

* **Returns:**
  the number of stores
* **Return type:**
  int

#### delete_store_global(store_name: str) → int

Delete a store from the global store collection.

* **Parameters:**
  **store_name** (*str*) – the name of the store to delete
* **Returns:**
  the number of documents deleted
* **Return type:**
  int

#### subscribe(store_name: str, callback: Callable[[str], None]) → str

Subscribe to changes in a store.

* **Parameters:**
  * **store_name** (*str*) – the name of the store to subscribe to
  * **callback** (*Callable* *[* *[**str* *]* *,* *None* *]*) – the callback to call when a change occurs
* **Returns:**
  the subscription ID
* **Return type:**
  str
* **Raises:**
  **ValueError** – if no notification service is available

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

Unsubscribe from changes in a store.

* **Parameters:**
  **subscription_id** (*str*) – the subscription ID to unsubscribe
* **Returns:**
  True if the subscription was removed, False otherwise
* **Return type:**
  [bool](fiftyone.core.stages.md#fiftyone.core.stages.Exists.bool)
* **Raises:**
  **ValueError** – if no notification service is available
