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.
|
boolean |
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)
A utility method for creating a VCache marshaller for the given serializable type, when that type also has a
generic signature, e.g.
|
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)
Create a wrapper around a
StableReadExternalCache with the given name and value type. |
static <V> SynchronousExternalCache<V> |
synchronousStableReadExternalCache(com.atlassian.vcache.VCacheFactory cacheFactory,
String cacheName,
com.atlassian.vcache.Marshaller<V> marshaller)
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.vcache.Marshaller<V> marshaller,
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.vcache.Marshaller<V> marshaller)
StableReadExternalCache
with the given name and marshaller.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.vcache.Marshaller<V> marshaller, 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)
public static <C extends T,T extends Serializable> com.atlassian.vcache.Marshaller<C> serializableMarshaller(Class<T> type)
public 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 boolean 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.Copyright © 2003–2016 Atlassian. All rights reserved.