public class SynchronousExternalCache<V> extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
SynchronousExternalCache.CacheException |
| Modifier and Type | Method and Description |
|---|---|
Optional<V> |
get(String key)
Get an entry from the cache.
|
<R> R |
get(String key,
Function<Optional<V>,R> onSuccess,
Function<Throwable,R> onError)
Get an entry from the cache.
|
Optional<V> |
get(String key,
Function<Throwable,Optional<V>> onError)
Get an entry from the cache.
|
V |
get(String key,
com.atlassian.util.concurrent.Supplier<V> valueLoader)
Get an entry from the cache.
|
Map<String,Optional<V>> |
getBulk(Iterable<String> keys)
Returns the values that are associated with the specified keys.
|
Map<String,Optional<V>> |
getBulk(Iterable keys,
Function<Throwable,Map<String,Optional<V>>> onError)
Returns the values that are associated with the specified keys.
|
Map<String,Optional<V>> |
getBulk(String... keys)
Returns the values that are associated with the specified keys.
|
void |
put(String key,
V value)
Puts an entry into the cache.
|
boolean |
put(String key,
V value,
com.atlassian.vcache.PutPolicy putPolicy)
Puts an entry into the cache.
|
boolean |
put(String key,
V value,
com.atlassian.vcache.PutPolicy putPolicy,
Consumer<Throwable> onError)
Puts an entry into the cache.
|
boolean |
put(String key,
V value,
com.atlassian.vcache.PutPolicy putPolicy,
Function<Throwable,Boolean> onError)
Puts an entry into the cache.
|
void |
remove(String key)
Removes a cache entry.
|
void |
remove(String key,
Consumer<Throwable> onError)
Removes a cache entry.
|
void |
removeAll()
Remove all entries from the cache
|
static <C extends T,T extends Serializable> |
serializableMarshaller(Class<T> type)
Deprecated.
Use
ProtobufMarshalling |
static <C extends com.atlassian.vcache.ExternalWriteOperationsUnbuffered<V> & com.atlassian.vcache.ExternalCache<V>,V> |
synchronous(C cache)
Create a wrapper around the given cache.
|
static <C extends com.atlassian.vcache.ExternalWriteOperationsUnbuffered<V> & com.atlassian.vcache.ExternalCache<V>,V> |
synchronous(com.atlassian.util.concurrent.Supplier<C> cacheRef)
Create a wrapper around the given cache supplier.
|
static <V extends Serializable> |
synchronousStableReadExternalCache(com.atlassian.vcache.VCacheFactory cacheFactory,
String cacheName,
Class<V> valueType)
|
static <V> SynchronousExternalCache<V> |
synchronousStableReadExternalCache(com.atlassian.vcache.VCacheFactory cacheFactory,
String cacheName,
com.atlassian.marshalling.api.MarshallingPair<V> valueMarshalling)
Create a wrapper around a
StableReadExternalCache with the given name and marshaller. |
static <V> SynchronousExternalCache<V> |
synchronousStableReadExternalCache(com.atlassian.vcache.VCacheFactory cacheFactory,
String cacheName,
com.atlassian.marshalling.api.MarshallingPair<V> valueMarshalling,
com.atlassian.vcache.ExternalCacheSettingsBuilder cacheSettingsBuilder)
Create a wrapper around a
StableReadExternalCache with the given name, marshaller and cache settings. |
public static <V> SynchronousExternalCache<V> synchronousStableReadExternalCache(com.atlassian.vcache.VCacheFactory cacheFactory, String cacheName, com.atlassian.marshalling.api.MarshallingPair<V> valueMarshalling)
StableReadExternalCache with the given name and marshaller.@Deprecated public static <V extends Serializable> SynchronousExternalCache<V> synchronousStableReadExternalCache(com.atlassian.vcache.VCacheFactory cacheFactory, String cacheName, Class<V> valueType)
StableReadExternalCache with the given name and value type.public static <V> SynchronousExternalCache<V> synchronousStableReadExternalCache(com.atlassian.vcache.VCacheFactory cacheFactory, String cacheName, com.atlassian.marshalling.api.MarshallingPair<V> valueMarshalling, com.atlassian.vcache.ExternalCacheSettingsBuilder cacheSettingsBuilder)
StableReadExternalCache with the given name, marshaller and cache settings.public static <C extends com.atlassian.vcache.ExternalWriteOperationsUnbuffered<V> & com.atlassian.vcache.ExternalCache<V>,V> SynchronousExternalCache<V> synchronous(com.atlassian.util.concurrent.Supplier<C> cacheRef)
public static <C extends com.atlassian.vcache.ExternalWriteOperationsUnbuffered<V> & com.atlassian.vcache.ExternalCache<V>,V> SynchronousExternalCache<V> synchronous(C cache)
@Deprecated public static <C extends T,T extends Serializable> com.atlassian.marshalling.api.MarshallingPair<C> serializableMarshaller(Class<T> type)
ProtobufMarshallingpublic void remove(String key)
key - the key of the entry to removeSynchronousExternalCache.CacheException - if the remove operation failspublic void remove(String key, Consumer<Throwable> onError)
key - the key of the entry to removeonError - The callback that will be invoked if the remove opertation failspublic void removeAll()
SynchronousExternalCache.CacheException - if the remove operation failspublic void put(String key, V value)
key - The key of the entryvalue - The value of the entrySynchronousExternalCache.CacheException - if the put operation failspublic boolean put(String key, V value, com.atlassian.vcache.PutPolicy putPolicy)
key - The key of the entryvalue - The value of the entryputPolicy - The required policySynchronousExternalCache.CacheException - if the put operation failspublic boolean put(String key, V value, com.atlassian.vcache.PutPolicy putPolicy, Consumer<Throwable> onError)
key - The key of the entryvalue - The value of the entryputPolicy - The required policyonError - The callback to invoked if the operation failspublic boolean put(String key, V value, com.atlassian.vcache.PutPolicy putPolicy, Function<Throwable,Boolean> onError)
key - The key of the entryvalue - The value of the entryputPolicy - The required policyonError - The function to invoked if the operation failspublic Optional<V> get(String key)
key - the key of the entryOptional.empty() if the get operation fails.public Optional<V> get(String key, Function<Throwable,Optional<V>> onError)
key - the key of the entryonError - The function to be invoked if the get operation failspublic <R> R get(String key, Function<Optional<V>,R> onSuccess, Function<Throwable,R> onError)
key - the key of the entryonSuccess - The function to invoked if the get operation succeeds (even if there's no entry for the key)onError - The function to be invoked if the get operation failspublic V get(String key, com.atlassian.util.concurrent.Supplier<V> valueLoader)
key - the key of the entryvalueLoader - The supplier of a value for a new cache entry if there is no entry for the key, or if the get operation fails.public Map<String,Optional<V>> getBulk(String... keys)
getBulk(Iterable) passing Arrays.asList(keys) as the parameter.public Map<String,Optional<V>> getBulk(Iterable<String> keys)
public Map<String,Optional<V>> getBulk(Iterable keys, Function<Throwable,Map<String,Optional<V>>> onError)
keys - the keys to check.onError - The function to be invoked if the get operation failsMap that is keyed on the keys specified. Each entry in the Map will have
Optional which may contain the value associated with the key. If the get operation fails, the result of
the error function is returned instead.Copyright © 2003–2016 Atlassian. All rights reserved.