Package ninja.cache
Class CacheMemcachedImpl
- java.lang.Object
-
- ninja.cache.CacheMemcachedImpl
-
-
Constructor Summary
Constructors Constructor Description CacheMemcachedImpl(org.slf4j.Logger logger, NinjaProperties ninjaProperties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String key, Object value, int expiration)Add object to cache.voidclear()Clear all values in cache.longdecr(String key, int by)Decrements key by value.voiddelete(String key)Delete key from cache.Objectget(String key)Returns the object for this key or null if not found.Map<String,Object>get(String[] keys)Returns all objects for the keys.longincr(String key, int by)Increments key by value.voidreplace(String key, Object value, int expiration)Replaces key with new value.booleansafeAdd(String key, Object value, int expiration)Similar todeletemethod.booleansafeDelete(String key)Similar todeletemethod.booleansafeReplace(String key, Object value, int expiration)Similar todeletemethod.booleansafeSet(String key, Object value, int expiration)Similar todeletemethod.voidset(String key, Object value, int expiration)Adds object of cache.voidstop()
-
-
-
Constructor Detail
-
CacheMemcachedImpl
@Inject public CacheMemcachedImpl(org.slf4j.Logger logger, NinjaProperties ninjaProperties) throws Exception- Throws:
Exception
-
-
Method Detail
-
add
public void add(String key, Object value, int expiration)
Description copied from interface:CacheAdd object to cache. Important: If the key exists already it won't be overwritten. Use set(...) instead. This method is fire and forget. Implementations may implement this async and non-blocking.
-
get
public Object get(String key)
Description copied from interface:CacheReturns the object for this key or null if not found.
-
clear
public void clear()
Description copied from interface:CacheClear all values in cache.
-
delete
public void delete(String key)
Description copied from interface:CacheDelete key from cache.
-
get
public Map<String,Object> get(String[] keys)
Description copied from interface:CacheReturns all objects for the keys.
-
incr
public long incr(String key, int by)
Description copied from interface:CacheIncrements key by value.
-
decr
public long decr(String key, int by)
Description copied from interface:CacheDecrements key by value.
-
replace
public void replace(String key, Object value, int expiration)
Description copied from interface:CacheReplaces key with new value. Important: Will do nothing if the key does not exist. This method is fire and forget. Implementations may implement this async and non-blocking.
-
safeAdd
public boolean safeAdd(String key, Object value, int expiration)
Description copied from interface:CacheSimilar todeletemethod. BUT it blocks until execution succeeds / fails AND wraps exceptions in a simple true / false return value
-
safeDelete
public boolean safeDelete(String key)
Description copied from interface:CacheSimilar todeletemethod. BUT it blocks until execution succeeds / fails AND wraps exceptions in a simple true / false return value- Specified by:
safeDeletein interfaceCache- Parameters:
key- The key to delete- Returns:
- true if deletion was successful, false if not.
-
safeReplace
public boolean safeReplace(String key, Object value, int expiration)
Description copied from interface:CacheSimilar todeletemethod. BUT it blocks until execution succeeds / fails AND wraps exceptions in a simple true / false return value- Specified by:
safeReplacein interfaceCache- Parameters:
key- The key of the object to use for caching.value- The value of the object to replace in the cache.expiration- Expiration time in seconds.- Returns:
- true if replace was successful, false if not.
-
safeSet
public boolean safeSet(String key, Object value, int expiration)
Description copied from interface:CacheSimilar todeletemethod. BUT it blocks until execution succeeds / fails AND wraps exceptions in a simple true / false return value
-
set
public void set(String key, Object value, int expiration)
Description copied from interface:CacheAdds object of cache. Important: This method potentially overwrites previously existing object with new values. This method is fire and forget. Implementations may implement this async and non-blocking.
-
stop
public void stop()
-
-