Class CachedMapFacade<V extends Cacheable>
- java.lang.Object
-
- edu.uiuc.ncsa.security.core.cache.CachedMapFacade<V>
-
- All Implemented Interfaces:
Store<V>
,Map<Identifier,V>
public abstract class CachedMapFacade<V extends Cacheable> extends Object implements Store<V>
A Facade for a map that is backed by a cache. Since all stores are logically maps as well, this can be used to cache any store.
Note: This persists immediately on put, so there are lazy reads but not writes. Gets to this are checked against the cache. If found, then that is returned, if not, the store is checked. Invoking put will either add a new item to the store or over-write an existing one with the same identifier. There is consequently a save operation implied with it.Usage
Extend this to the correct parameters. Implement any interfaces you need for storage then set the backing store to be your real store and use this class everyplace you would normally have your store.
This will remove from the store immediately as well.Created by Jeff Gaynor
on Nov 12, 2010 at 11:31:47 AM
-
-
Field Summary
-
Fields inherited from interface edu.uiuc.ncsa.security.core.Store
VERSION_TAG
-
-
Constructor Summary
Constructors Constructor Description CachedMapFacade()
CachedMapFacade(Store<V> theStore)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<Identifier,V>>
entrySet()
V
get(Object key)
Cache
getCache()
Store<V>
getTheStore()
boolean
hasStore()
boolean
isEmpty()
Set<Identifier>
keySet()
V
put(Identifier key, V cacheable)
void
putAll(Map<? extends Identifier,? extends V> m)
V
remove(Object key)
void
setCache(Cache cache)
void
setTheStore(Store<V> theStore)
int
size()
Collection<V>
values()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
getCache
public Cache getCache()
-
setCache
public void setCache(Cache cache)
-
hasStore
public boolean hasStore()
-
clear
public void clear()
- Specified by:
clear
in interfaceMap<Identifier,V extends Cacheable>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceMap<Identifier,V extends Cacheable>
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<Identifier,V extends Cacheable>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<Identifier,V extends Cacheable>
-
put
public V put(Identifier key, V cacheable)
- Specified by:
put
in interfaceMap<Identifier,V extends Cacheable>
-
remove
public V remove(Object key)
- Specified by:
remove
in interfaceMap<Identifier,V extends Cacheable>
-
putAll
public void putAll(Map<? extends Identifier,? extends V> m)
- Specified by:
putAll
in interfaceMap<Identifier,V extends Cacheable>
-
entrySet
public Set<Map.Entry<Identifier,V>> entrySet()
- Specified by:
entrySet
in interfaceMap<Identifier,V extends Cacheable>
-
size
public int size()
- Specified by:
size
in interfaceMap<Identifier,V extends Cacheable>
-
keySet
public Set<Identifier> keySet()
- Specified by:
keySet
in interfaceMap<Identifier,V extends Cacheable>
-
values
public Collection<V> values()
- Specified by:
values
in interfaceMap<Identifier,V extends Cacheable>
-
-