Class MapCache
- java.lang.Object
-
- org.dspace.services.caching.model.MapCache
-
-
Field Summary
Fields Modifier and Type Field Description protected CacheConfig
cacheConfig
protected String
name
-
Constructor Summary
Constructors Constructor Description MapCache(String name, CacheConfig cacheConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear out all cached items from this cache.boolean
exists(String key)
Check if a key exists in the cache.Object
get(String key)
Gets an object from the cache if it can be found (maybe be a null).Map<String,Object>
getCache()
CacheConfig
getConfig()
Returns a readable object which has the configuration used by this cache in it.List<String>
getKeys()
Provides a method for finding out what keys are currently in the cache or getting all items out of the cache.String
getName()
Get the unique name which identifies this cache.Object
look(String key)
Gets an object from the cache without causing it to be refreshed or renewed.void
put(String key, Object value)
Puts an object in the cache which is identified by this key.boolean
remove(String key)
Removes an object from the cache if it exists or does nothing if it does not.int
size()
How many items does this cache hold?String
toString()
-
-
-
Field Detail
-
name
protected String name
-
cacheConfig
protected CacheConfig cacheConfig
-
-
Constructor Detail
-
MapCache
public MapCache(String name, CacheConfig cacheConfig)
-
-
Method Detail
-
clear
public void clear()
Description copied from interface:Cache
Clear out all cached items from this cache.
-
exists
public boolean exists(String key)
Description copied from interface:Cache
Check if a key exists in the cache.
-
get
public Object get(String key)
Description copied from interface:Cache
Gets an object from the cache if it can be found (maybe be a null). Use the exists check to see if the object is in the cache before retrieving.
-
getKeys
public List<String> getKeys()
Description copied from interface:Cache
Provides a method for finding out what keys are currently in the cache or getting all items out of the cache. The keys are returned in no particular order.NOTE: that this is actually quite costly in most cases and should only be used when really needed. It is much better to fetch the items you actually need directly using
Cache.get(String)
.
-
getConfig
public CacheConfig getConfig()
Description copied from interface:Cache
Returns a readable object which has the configuration used by this cache in it.
-
getName
public String getName()
Description copied from interface:Cache
Get the unique name which identifies this cache.
-
look
public Object look(String key)
Description copied from interface:Cache
Gets an object from the cache without causing it to be refreshed or renewed. LikeCache.get(String)
except that it keeps the cache from refreshing the item that was retrieved.- Specified by:
look
in interfaceCache
- Parameters:
key
- the key for an item in the cache- Returns:
- the cached object (may be null) OR null if the cache object cannot be found
- See Also:
Cache.get(String)
-
put
public void put(String key, Object value)
Description copied from interface:Cache
Puts an object in the cache which is identified by this key. Will overwrite an existing object if one is already using this key.
-
remove
public boolean remove(String key)
Description copied from interface:Cache
Removes an object from the cache if it exists or does nothing if it does not.
-
size
public int size()
Description copied from interface:Cache
How many items does this cache hold?
-
-