public class SerializableUserCache<V> extends AbstractFileSystemCache<V>
Efficient implementation of ApplicationCache for authentication sub-systems.
cache, ttl, ttlUnit| Constructor and Description |
|---|
SerializableUserCache()
Constructs a
SerializableUserCache. |
SerializableUserCache(String cacheDir,
String cacheFile)
Constructs a
SerializableUserCache with the given type of user 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 SerializableUserCache()
Constructs a SerializableUserCache. Sensible defaults will be used for required
parameters unless explicitly set. An application can typically have several instances of user
cache to store different types of user details (for example, a scenario with multiple
authentication/authorization providers using different user details services).
public SerializableUserCache(String cacheDir, String cacheFile)
Constructs a SerializableUserCache with the given type of user 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 user cache to store
different types of user details (for example, a scenario with multiple
authentication/authorization providers using different user details services).
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.