public class SerializableCsrfCache<V> extends AbstractFileSystemCache<V>
Efficient implementation of ApplicationCache for CSRF Filters.
cache, ttl, ttlUnit| Constructor and Description |
|---|
SerializableCsrfCache()
Constructs a
SerializableCsrfCache. |
SerializableCsrfCache(String cacheDir,
String cacheFile)
Constructs a
SerializableCsrfCache with the given type of auth token, 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 SerializableCsrfCache()
Constructs a SerializableCsrfCache. Sensible defaults will be used for required
parameters unless explicitly set.
public SerializableCsrfCache(String cacheDir, String cacheFile)
Constructs a SerializableCsrfCache with the given type of auth token, the cache
storage directory and cache file name. Provides better control on caching strategy out of the
box.
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.