Class InMemorySnapshotStore
- All Implemented Interfaces:
SnapshotStore
SnapshotStore for testing or lightweight scenarios.
This store keeps snapshots in memory only and does not persist them to any durable storage. It is thread-safe.
Snapshots are stored by their qualified name and identifier.
All operations return CompletableFuture to conform with the SnapshotStore
asynchronous API, but they complete immediately since storage is in-memory.
- Since:
- 5.1.0
- Author:
- John Hendrikx
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCompletableFuture<@Nullable Snapshot> load(QualifiedName qualifiedName, Object identifier) Loads the latest snapshot for a given name and identifier.store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot) Persists a snapshot under the given name and identifier.
-
Constructor Details
-
InMemorySnapshotStore
public InMemorySnapshotStore()
-
-
Method Details
-
store
public CompletableFuture<Void> store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot) Description copied from interface:SnapshotStorePersists a snapshot under the given name and identifier. This replaces any previous snapshot(s) with the same name and identifier.This method is asynchronous and returns a
CompletableFuturethat completes when the snapshot has been durably stored.- Specified by:
storein interfaceSnapshotStore- Parameters:
qualifiedName- the name of the snapshot to persist, cannot benullidentifier- the identifier of the snapshot to persist, cannot benullsnapshot- the snapshot to persist, cannot benull- Returns:
- a
CompletableFuturethat completes when the snapshot has been stored
-
load
Description copied from interface:SnapshotStoreLoads the latest snapshot for a given name and identifier.The returned snapshot may have an older or newer version relative to what is expected. The caller is responsible for handling version compatibility or ignoring unusable snapshots.
This method is asynchronous and returns a
CompletableFuturethat completes with the snapshot if one exists, ornullif no snapshot is available.- Specified by:
loadin interfaceSnapshotStore- Parameters:
qualifiedName- the name of the snapshot, cannot benullidentifier- the identifier of the snapshot, cannot benull- Returns:
- a
CompletableFuturecontaining the snapshot, or containingnullif no matching snapshot exists
-