com.parthparekh.service.cache
Class MemcachedImpl

java.lang.Object
  extended by com.parthparekh.service.cache.MemcachedImpl
All Implemented Interfaces:
Cache

public class MemcachedImpl
extends java.lang.Object
implements Cache

Memcache cache implementation


Field Summary
private  net.spy.memcached.MemcachedClientIF cache
           
private static org.slf4j.Logger logger
           
private  org.codehaus.jackson.map.ObjectMapper objectMapper
           
 
Constructor Summary
MemcachedImpl()
           
 
Method Summary
 boolean evict(java.lang.String key)
          Removes data from cache with specified key
<T> T
get(java.lang.String key, java.lang.Class<T> clazz)
          Retrieves data from cache with specified key
 CacheType getType()
          Returns the CacheType for the cache
<T> boolean
put(java.lang.String key, T value)
          Adds data to the cache
<T> boolean
put(java.lang.String key, T value, int ttl)
          Adds data to the cache with specific ttl
 void setCache(net.spy.memcached.MemcachedClientIF cache)
           
 void setObjectMapper(org.codehaus.jackson.map.ObjectMapper objectMapper)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static org.slf4j.Logger logger

cache

private net.spy.memcached.MemcachedClientIF cache

objectMapper

@Autowired
@Qualifier(value="defaultObjectMapper")
private org.codehaus.jackson.map.ObjectMapper objectMapper
Constructor Detail

MemcachedImpl

public MemcachedImpl()
Method Detail

setObjectMapper

public void setObjectMapper(org.codehaus.jackson.map.ObjectMapper objectMapper)

setCache

public void setCache(net.spy.memcached.MemcachedClientIF cache)

put

public <T> boolean put(java.lang.String key,
                       T value)
Description copied from interface: Cache
Adds data to the cache

Specified by:
put in interface Cache
Parameters:
key - - cache key
value - - value of object
Returns:
true if the operation is successful, false otherwise

put

public <T> boolean put(java.lang.String key,
                       T value,
                       int ttl)
Description copied from interface: Cache
Adds data to the cache with specific ttl

Specified by:
put in interface Cache
Parameters:
key - - cache key
value - - value of object
ttl - in seconds
Returns:
true if the operation is successful, false otherwise

evict

public boolean evict(java.lang.String key)
Description copied from interface: Cache
Removes data from cache with specified key

Specified by:
evict in interface Cache
Parameters:
key - - cache key
Returns:
true if the operation is successful, false otherwise

get

public <T> T get(java.lang.String key,
                 java.lang.Class<T> clazz)
Description copied from interface: Cache
Retrieves data from cache with specified key

Specified by:
get in interface Cache
Parameters:
key - - cache key
clazz - - class type of object
Returns:
value of T object, null otherwise

getType

public CacheType getType()
Description copied from interface: Cache
Returns the CacheType for the cache

Specified by:
getType in interface Cache
Returns:
the CacheType of the cache