- java.lang.Object
-
- com.erudika.para.core.cache.MockCache
-
-
Constructor Summary
Constructors Constructor Description MockCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(String id)Do we have this object in the cache?booleancontains(String appid, String id)Do we have this object in the cache?<T> Tget(String id)Read an object from cache.<T> Tget(String appid, String id)Read an object from cache.<T> Map<String,T>getAll(String appid, List<String> ids)Read a number of objects given a list of their ids.<T> Map<String,T>getAll(List<String> ids)Read a number of objects given a list of their ids.<T> voidput(String appid, String id, T object)Store an object in the cache.<T> voidput(String appid, String id, T object, Long ttlSeconds)Store an object in the cache.<T> voidput(String id, T object)Store an object in the cache.<T> voidputAll(String appid, Map<String,T> objects)Store all objects in cache, except those which are null.<T> voidputAll(Map<String,T> objects)Store all objects in cache, except those which are null.voidremove(String id)Remove an object from cache.voidremove(String appid, String id)Remove an object from cache.voidremoveAll()Clears the cache.voidremoveAll(String appid)Clears the cache.voidremoveAll(String appid, List<String> ids)Remove a number of objects from cache given a list of their ids.voidremoveAll(List<String> ids)Remove a number of objects from cache given a list of their ids.
-
-
-
Method Detail
-
contains
public boolean contains(String appid, String id)
Description copied from interface:CacheDo we have this object in the cache?- Specified by:
containsin interfaceCache- Parameters:
appid- the name of the applicationid- the object's id- Returns:
- true if in cache
- See Also:
Cache.contains(java.lang.String)
-
put
public <T> void put(String appid, String id, T object)
Description copied from interface:CacheStore an object in the cache.- Specified by:
putin interfaceCache- Type Parameters:
T- the type of object to be cached- Parameters:
appid- the name of the applicationid- the object's id, not null or emptyobject- the object itself, not null- See Also:
Cache.put(java.lang.String, java.lang.Object)
-
put
public <T> void put(String appid, String id, T object, Long ttlSeconds)
Description copied from interface:CacheStore an object in the cache.- Specified by:
putin interfaceCache- Type Parameters:
T- the type of object to be cached- Parameters:
appid- the name of the applicationid- the object's id, not null or emptyobject- the object itself, not nullttlSeconds- the time to live for an object before it is evicted from the cache.- See Also:
Cache.put(java.lang.String, java.lang.Object)
-
putAll
public <T> void putAll(String appid, Map<String,T> objects)
Description copied from interface:CacheStore all objects in cache, except those which are null.- Specified by:
putAllin interfaceCache- Type Parameters:
T- any object, not null- Parameters:
appid- the name of the applicationobjects- map of id - object- See Also:
Cache.putAll(java.util.Map)
-
get
public <T> T get(String appid, String id)
Description copied from interface:CacheRead an object from cache.- Specified by:
getin interfaceCache- Type Parameters:
T- the type of object to be cached- Parameters:
appid- the name of the applicationid- the object's id, not null or empty- Returns:
- the object from cache or null if not found
- See Also:
Cache.get(java.lang.String)
-
getAll
public <T> Map<String,T> getAll(String appid, List<String> ids)
Description copied from interface:CacheRead a number of objects given a list of their ids.- Specified by:
getAllin interfaceCache- Type Parameters:
T- the type of object to be cached- Parameters:
appid- the name of the applicationids- the ids, not null or empty- Returns:
- a map of the objects that are contained in cache (may be empty)
- See Also:
Cache.getAll(java.util.List)
-
remove
public void remove(String appid, String id)
Description copied from interface:CacheRemove an object from cache.- Specified by:
removein interfaceCache- Parameters:
appid- the name of the applicationid- the object's id, not null or empty- See Also:
Cache.remove(java.lang.String)
-
removeAll
public void removeAll(String appid)
Description copied from interface:CacheClears the cache.- Specified by:
removeAllin interfaceCache- Parameters:
appid- the name of the application- See Also:
Cache.removeAll()
-
removeAll
public void removeAll(String appid, List<String> ids)
Description copied from interface:CacheRemove a number of objects from cache given a list of their ids.- Specified by:
removeAllin interfaceCache- Parameters:
appid- the name of the applicationids- the ids, not null or empty- See Also:
Cache.removeAll(java.util.List)
-
contains
public boolean contains(String id)
Description copied from interface:CacheDo we have this object in the cache?
-
put
public <T> void put(String id, T object)
Description copied from interface:CacheStore an object in the cache.
-
putAll
public <T> void putAll(Map<String,T> objects)
Description copied from interface:CacheStore all objects in cache, except those which are null.
-
get
public <T> T get(String id)
Description copied from interface:CacheRead an object from cache.
-
getAll
public <T> Map<String,T> getAll(List<String> ids)
Description copied from interface:CacheRead a number of objects given a list of their ids.
-
remove
public void remove(String id)
Description copied from interface:CacheRemove an object from cache.
-
removeAll
public void removeAll()
Description copied from interface:CacheClears the cache.
-
-