Package de.otto.synapse.state
Class ChronicleMapStateRepository<V>
java.lang.Object
de.otto.synapse.state.ConcurrentMapStateRepository<V>
de.otto.synapse.state.ChronicleMapStateRepository<V>
- Type Parameters:
V- The type of the event-sourced entities stored in theStateRepository
- All Implemented Interfaces:
StateRepository<V>,java.lang.AutoCloseable
public class ChronicleMapStateRepository<V> extends ConcurrentMapStateRepository<V>
A
StateRepository that is using a ChronicleMap to store the event-sourced entities off the heap.
Suitable for larger amounts of data, without problems because of garbage-collection issues because of the usage of off-heap memory.
In order to be able to access the ConcurrentMapStateRepository.keySet() of the stored entities, this implementation is storing
a copy of the keys in a separate ConcurrentSkipListSet
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classChronicleMapStateRepository.Builder<V> -
Method Summary
Modifier and Type Method Description static <V> ChronicleMapStateRepository.Builder<V>builder(java.lang.Class<V> clazz)java.util.Optional<V>get(java.lang.String key)Returns the optional value to which the specified key is mapped, orOptional.empty()if this repository contains no mapping for the key.java.util.Optional<V>put(java.lang.String key, V value)Associates the specified value with the specified key in this repository.longsize()Returns the number of key-value mappings in this repository.Methods inherited from class de.otto.synapse.state.ConcurrentMapStateRepository
clear, close, compute, consumeAll, getName, keySet, removeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
put
Description copied from interface:StateRepositoryAssociates the specified value with the specified key in this repository. If the repository previously contained a mapping for the key, the old value is replaced by the specified value. (A repository m is said to contain a mapping for a key k if and only ifm.get(k)would return a non-empty value.)- Specified by:
putin interfaceStateRepository<V>- Overrides:
putin classConcurrentMapStateRepository<V>- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Returns:
- the previous value associated with 'key', or 'Optional.empty()' if there was no mapping for 'key'
-
get
Description copied from interface:StateRepositoryReturns the optional value to which the specified key is mapped, orOptional.empty()if this repository contains no mapping for the key.More formally, if this repository contains a mapping from a key
kto a valuevsuch that(key==null ? k==null : key.equals(k)), then this method returnsOptional.of(v); otherwise it returnsOptional.empty(). (There can be at most one such mapping.)- Specified by:
getin interfaceStateRepository<V>- Overrides:
getin classConcurrentMapStateRepository<V>- Parameters:
key- the key whose associated value is to be returned- Returns:
- the Optional containing the value to which the specified key is mapped, or
Optional.empty()if this repository contains no mapping for the key
-
size
public long size()Description copied from interface:StateRepositoryReturns the number of key-value mappings in this repository. If the repository contains more than 'Integer.MAX_VALUE' elements, returns 'Integer.MAX_VALUE'.- Specified by:
sizein interfaceStateRepository<V>- Overrides:
sizein classConcurrentMapStateRepository<V>- Returns:
- the number of key-value mappings in this repository
-
builder
-