net.sf.dict4j.cache
Class MemoryCacheProvider

java.lang.Object
  extended by net.sf.dict4j.cache.MemoryCacheProvider
All Implemented Interfaces:
CacheProvider

public class MemoryCacheProvider
extends java.lang.Object
implements CacheProvider


Constructor Summary
MemoryCacheProvider(long expirationInSeconds)
           
 
Method Summary
 void add(CacheKey key, java.lang.Object value)
          Add object to cache
 void clear()
          Clear cache
 java.lang.Object get(CacheKey key)
          Get cache object by key
 java.util.ArrayList<CacheKey> getExpiredKeys()
           
 long getHitsNumber()
           
 void invalidateCache()
          Check all cache entries and remove expired ones
 void remove(CacheKey key)
          Remove object from cache by key
 void setExpirationInSeconds(long expirationInSeconds)
           
 int size()
          Get number of entities in cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryCacheProvider

public MemoryCacheProvider(long expirationInSeconds)
Method Detail

add

public void add(CacheKey key,
                java.lang.Object value)
Add object to cache

Specified by:
add in interface CacheProvider
Parameters:
key - cache key
value - object

get

public java.lang.Object get(CacheKey key)
Get cache object by key

Specified by:
get in interface CacheProvider
Parameters:
key - cache key
Returns:
object

remove

public void remove(CacheKey key)
Remove object from cache by key

Specified by:
remove in interface CacheProvider
Parameters:
key - cache key

invalidateCache

public void invalidateCache()
Check all cache entries and remove expired ones

Specified by:
invalidateCache in interface CacheProvider

getExpiredKeys

public java.util.ArrayList<CacheKey> getExpiredKeys()

size

public int size()
Get number of entities in cache

Specified by:
size in interface CacheProvider
Returns:
number of entities in cache

clear

public void clear()
Clear cache

Specified by:
clear in interface CacheProvider

setExpirationInSeconds

public void setExpirationInSeconds(long expirationInSeconds)

getHitsNumber

public long getHitsNumber()