Package org.mockserver.state
Class InMemoryStateBackend
java.lang.Object
org.mockserver.state.InMemoryStateBackend
- All Implemented Interfaces:
Closeable,AutoCloseable,StateBackend
Default in-memory
StateBackend that wraps today's exact data
structures for zero behaviour change. Every store is node-local;
there is no network I/O or clustering in this implementation.-
Constructor Summary
ConstructorsConstructorDescriptionInMemoryStateBackend(int maxExpectations) InMemoryStateBackend(int maxExpectations, BlobStore blobStore) Creates an in-memory state backend with an externally-suppliedBlobStore. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInvalidationListener(InvalidationListener listener) Adds an invalidation listener that receives change notifications from ALL stores managed by this backend.blobs()Returns the blob store for persisted expectations, recorded cassettes, fixtures, and snapshots.voidclose()Closes the backend and releases any resources.KeyValueStore<com.fasterxml.jackson.databind.node.ObjectNode>crudEntities(String namespace) Returns a CRUD entity key-value store for the given namespace.Returns the expectation key-value store.Returns the expectation store cast to its concrete type, so callers that need the sorted-list or queue API can access it.nodeId()Returns a unique identifier for this node/instance.Returns the scenario-state key-value store.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.mockserver.state.StateBackend
isClustered
-
Constructor Details
-
InMemoryStateBackend
public InMemoryStateBackend(int maxExpectations) -
InMemoryStateBackend
Creates an in-memory state backend with an externally-suppliedBlobStore. This allows theStateBackendFactoryto inject aFilesystemBlobStorewhenblobStoreType=filesystemwhile keeping the KV stores in-memory.- Parameters:
maxExpectations- maximum number of expectationsblobStore- the blob store implementation to use
-
-
Method Details
-
expectations
Description copied from interface:StateBackendReturns the expectation key-value store. The in-memory implementation internally wraps aCircularPriorityQueuefor identical ordering and eviction behaviour.- Specified by:
expectationsin interfaceStateBackend
-
expectationStore
Returns the expectation store cast to its concrete type, so callers that need the sorted-list or queue API can access it. -
scenarioStates
Description copied from interface:StateBackendReturns the scenario-state key-value store. Keys are composite scenario-name + isolation strings; values are state strings.- Specified by:
scenarioStatesin interfaceStateBackend
-
crudEntities
Description copied from interface:StateBackendReturns a CRUD entity key-value store for the given namespace. Each namespace corresponds to a distinct CRUD resource path.- Specified by:
crudEntitiesin interfaceStateBackend
-
blobs
Description copied from interface:StateBackendReturns the blob store for persisted expectations, recorded cassettes, fixtures, and snapshots.- Specified by:
blobsin interfaceStateBackend
-
addInvalidationListener
Description copied from interface:StateBackendAdds an invalidation listener that receives change notifications from ALL stores managed by this backend.- Specified by:
addInvalidationListenerin interfaceStateBackend
-
nodeId
Description copied from interface:StateBackendReturns a unique identifier for this node/instance. Used to distinguish local vs. remote writes in a clustered backend.- Specified by:
nodeIdin interfaceStateBackend
-
close
public void close()Description copied from interface:StateBackendCloses the backend and releases any resources. No-op for the in-memory backend.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceStateBackend
-