Class ReplicatorMessageSerializer.SmallCache<A,B>
java.lang.Object
org.apache.pekko.cluster.ddata.protobuf.ReplicatorMessageSerializer.SmallCache<A,B>
- Enclosing class:
- ReplicatorMessageSerializer
A 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.
evict must be called from the outside, i.e. the
cache will not cleanup itself.
-
Constructor Summary
ConstructorsConstructorDescriptionSmallCache(int size, scala.concurrent.duration.FiniteDuration timeToLive, scala.Function1<A, B> getOrAddFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd entry to the cache.voidvoidevict()Remove all elements if the cache has not been used within thetimeToLive.Get value from cache ornullif it doesn't exist.Get value from cache or create new value with thegetOrAddFactorythat was given in the constructor.toString()
-
Constructor Details
-
SmallCache
-
-
Method Details
-
add
Add entry to the cache. Overwrites oldest entry. -
add
-
evict
public void evict()Remove all elements if the cache has not been used within thetimeToLive. -
get
Get value from cache ornullif it doesn't exist. -
getOrAdd
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. -
toString
-