Class ReplicatorMessageSerializer.SmallCache<A,B>
- java.lang.Object
- 
- org.apache.pekko.cluster.ddata.protobuf.ReplicatorMessageSerializer.SmallCache<A,B>
 
- 
- Enclosing class:
- ReplicatorMessageSerializer
 
 public static final class ReplicatorMessageSerializer.SmallCache<A,B> extends java.lang.ObjectA cache that is designed for a small number (<= 32) of entries. It is using instance equality. Adding new entry overwrites oldest. It is thread safe but duplicates of same entry may occur.evictmust be called from the outside, i.e. the cache will not cleanup itself.
- 
- 
Constructor SummaryConstructors Constructor Description SmallCache(int size, scala.concurrent.duration.FiniteDuration timeToLive, scala.Function1<A,B> getOrAddFactory)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(A a, B b)Add entry to the cache.voidadd(scala.Tuple2<A,B> x)voidevict()Remove all elements if the cache has not been used within thetimeToLive.Bget(A a)Get value from cache ornullif it doesn't exist.BgetOrAdd(A a)Get value from cache or create new value with thegetOrAddFactorythat was given in the constructor.java.lang.StringtoString()
 
- 
- 
- 
Method Detail- 
evictpublic void evict() Remove all elements if the cache has not been used within thetimeToLive.
 - 
getOrAddpublic B getOrAdd(A a) Get value from cache or create new value with thegetOrAddFactorythat was given in the constructor. The new value is added to the cache. Duplicates of same value may be added if multiple threads call this concurrently, but decent (low cost) effort is made to reduce the chance of duplicates.
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-