public static final class ReplicatorMessageSerializer.SmallCache<A,B>
extends java.lang.Object
evict
must be called from the outside, i.e. the
cache will not cleanup itself.
Constructor and Description |
---|
SmallCache(int size,
scala.concurrent.duration.FiniteDuration timeToLive,
scala.Function1<A,B> getOrAddFactory) |
Modifier and Type | Method and Description |
---|---|
void |
add(A a,
B b)
Add entry to the cache.
|
void |
add(scala.Tuple2<A,B> x) |
void |
evict()
Remove all elements if the cache has not been
used within the
timeToLive . |
B |
get(A a)
Get value from cache or
null if it doesn't exist. |
B |
getOrAdd(A a)
Get value from cache or create new value with the
getOrAddFactory that was given in the constructor. |
java.lang.String |
toString() |
public B get(A a)
null
if it doesn't exist.a
- (undocumented)public void add(A a, B b)
a
- (undocumented)b
- (undocumented)public B getOrAdd(A a)
getOrAddFactory
that 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.a
- (undocumented)public void evict()
timeToLive
.public java.lang.String toString()
toString
in class java.lang.Object