Class ProtobufRedisLoadingCache<K extends com.google.protobuf.Message,V extends com.google.protobuf.Message>
- java.lang.Object
 - 
- org.curioswitch.common.server.framework.redis.ProtobufRedisLoadingCache<K,V>
 
 
- 
public class ProtobufRedisLoadingCache<K extends com.google.protobuf.Message,V extends com.google.protobuf.Message> extends java.lang.ObjectAAsyncLoadingCachethat is backed by a remote remoteCache cache, specialized for the common case where the key and value are protobuf for easy serialization. This class should be used even when no local caching is desired as it ensures multiple reads of the same key share the same write to remoteCache. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProtobufRedisLoadingCache.FactoryAProtobufRedisLoadingCache.Factoryfor creatingProtobufRedisLoadingCache. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.util.concurrent.ListenableFuture<java.lang.Boolean>deleteFromRedis(K key)Deletes the givenkeyfrom the remote cache.com.google.common.util.concurrent.ListenableFuture<V>get(K key, java.util.function.Function<K,com.google.common.util.concurrent.ListenableFuture<V>> loader)Returns the value for the givenkey, computing the value fromloaderif it is not present in cache.com.google.common.util.concurrent.ListenableFuture<V>getIfPresent(K key)Returns the value for the givenkeyif it is present in cache, otherwise returnsnull.com.google.common.util.concurrent.ListenableFuture<V>put(K key, V value)Sets the givenvaluefor the givenkeyin cache. 
 - 
 
- 
- 
Method Detail
- 
get
public com.google.common.util.concurrent.ListenableFuture<V> get(K key, java.util.function.Function<K,com.google.common.util.concurrent.ListenableFuture<V>> loader)
Returns the value for the givenkey, computing the value fromloaderif it is not present in cache. 
- 
getIfPresent
public com.google.common.util.concurrent.ListenableFuture<V> getIfPresent(K key)
Returns the value for the givenkeyif it is present in cache, otherwise returnsnull. 
- 
put
public com.google.common.util.concurrent.ListenableFuture<V> put(K key, V value)
Sets the givenvaluefor the givenkeyin cache. Simultaneous writes to the same key will result in consecutive updates, so this method should only be used when this is acceptable (e.g., for storing state that might be used to resume an operation). For general cache semantics, useget(Message, Function). 
- 
deleteFromRedis
public com.google.common.util.concurrent.ListenableFuture<java.lang.Boolean> deleteFromRedis(K key)
Deletes the givenkeyfrom the remote cache. This can be used to invalidate remote caches. It is not practical to invalidate local caches across servers, so this is only useful if the local cache is disabled everywhere (i.e.,localCacheSpecis null on construction).- Returns:
 - a 
ListenableFuturewhich completes withtrueif the key was present and deleted orfalseif the key was not present at all. 
 
 - 
 
 -