com.parthparekh.service.cache
Class EhCacheImpl

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

public class EhCacheImpl
extends java.lang.Object
implements Cache

Memcache cache implementation


Field Summary
private  net.sf.ehcache.Ehcache cache
           
private static org.slf4j.Logger logger
           
 
Constructor Summary
EhCacheImpl()
           
 
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
 net.sf.ehcache.Ehcache getCache()
           
 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 removeAll()
           
 void setCache(net.sf.ehcache.Ehcache cache)
           
 
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.sf.ehcache.Ehcache cache
Constructor Detail

EhCacheImpl

public EhCacheImpl()
Method Detail

getCache

public net.sf.ehcache.Ehcache getCache()

setCache

public void setCache(net.sf.ehcache.Ehcache 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

removeAll

public void removeAll()