public class SerializableGenericCache<V> extends AbstractFileSystemCache<V>
Efficient implementation of ApplicationCache for
non-differential subsystems which are unknown to this API (better support for
runtime resolution will be provided in future when out team gets the chance
to look into this).
cache, ttl, ttlUnit| Constructor and Description |
|---|
SerializableGenericCache()
Constructs a
SerializableGenericCache. |
SerializableGenericCache(String cacheDir,
String cacheFile)
Constructs a
SerializableGenericCache with the given type of
referenced details, the cache storage directory and cache file name. |
| Modifier and Type | Method and Description |
|---|---|
void |
evictFromCache(Object key)
Removes the specified entry from the cache.
|
V |
getFromCache(Object key)
Obtains a stored entry from the cache.
|
void |
putInCache(Object key,
V entry)
Places an entry in the cache.
|
afterPropertiesSet, destroy, flush, generate, getTtl, getTtlUnit, initialize, isPresentInCache, setCacheDir, setCacheFile, setTtlpublic SerializableGenericCache()
Constructs a SerializableGenericCache. Sensible defaults
will be used for required parameters unless explicitly set. An
application can typically have several instances of generic cache to
store different types of non-differential details.
public SerializableGenericCache(String cacheDir, String cacheFile)
Constructs a SerializableGenericCache with the given type of
referenced details, the cache storage directory and cache file name.
Provides better control on caching strategy out of the box. An
application can typically have several instances of generic cache to
store different types of non-differential details.
cacheDir - the cache directory location to usecacheFile - the cache file namepublic V getFromCache(Object key)
ApplicationCacheObtains a stored entry from the cache. Implementations must make sure not to throw an exception even if one occurs here.
Important: Note that you may use any well known java type as key like
Long or String or a custom type as long as it abides by
the contract defined by the Key interface, i.e., the key
should be uniquely identifiable using its value and not the Key instance as
whole. In short, you must override the Object.equals(Object) and
Object.hashCode() methods of that particular key type to make sure your identifier
can be uniquely distinguished from with-in the cache.
key - the unique identifier to use for fetching the entry; be advised that the same
identifier must be used for saving the details into the cachepublic void putInCache(Object key, V entry)
ApplicationCache
Places an entry in the cache. The key is the identifier used to subsequently
retrieve the entry.
Important: Note that you may use any well known java type as key like
Long or String or a custom type as long as it abides by
the contract defined by the Key interface, i.e., the key
should be uniquely identifiable using its value and not the Key instance as
whole. In short, you must override the Object.equals(Object) and
Object.hashCode() methods of that particular key type to make sure your identifier
can be uniquely distinguished from with-in the cache.
key - the key corresponding to which entry must be stored in the cacheentry - the object entry to place into the cachepublic void evictFromCache(Object key)
ApplicationCache
Removes the specified entry from the cache. The key is the identifier used to
remove the entry. If the entry is not found, the method should simply return (not throw an
exception).
Some cache implementations may not support eviction from the cache, in which case they should provide appropriate behavior to alter the token in either its documentation, via an exception, or through a log message.
Important: Note that you may use any well known java type as key like
Long or String or a custom type as long as it abides by
the contract defined by the Key interface, i.e., the key
should be uniquely identifiable using its value and not the Key instance as
whole. In short, you must override the Object.equals(Object) and
Object.hashCode() methods of that particular key type to make sure your identifier
can be uniquely distinguished from with-in the cache.
key - the predefined key/identifier for evicting an entry from the cacheCopyright © 2016. All rights reserved.