org.rythmengine.cache
Class SimpleCacheService

java.lang.Object
  extended by org.rythmengine.cache.SimpleCacheService
All Implemented Interfaces:
ICacheService

public class SimpleCacheService
extends Object
implements ICacheService

A simple cache service implementation


Field Summary
static SimpleCacheService INSTANCE
           
 
Method Summary
 void clear()
          Remove all cached items
 boolean contains(String key)
          Check if the cache contains key
protected  void finalize()
           
 Serializable get(String key)
          Return an item from the cache service by key
 void put(String key, Serializable value)
          Store an item into the cache by key and use default ttl
 void put(String key, Serializable value, int ttl)
          Store an item into the cache service by key and set ttl value
 Serializable remove(String key)
          Remove an item from cache service by key
 void setDefaultTTL(int ttl)
          Set default ttl value which will be used if user pass 0 as ttl or not specified ttl
 void shutdown()
          Shutdown the cache service
 void startup()
          Restart the cache service after shutdown
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final SimpleCacheService INSTANCE
Method Detail

put

public void put(String key,
                Serializable value,
                int ttl)
Description copied from interface: ICacheService
Store an item into the cache service by key and set ttl value

Specified by:
put in interface ICacheService
ttl - time to live of the cached item. Time unit is second. If set to negative number, then it will never expire. If set to zero then the default ttl value will be used

put

public void put(String key,
                Serializable value)
Description copied from interface: ICacheService
Store an item into the cache by key and use default ttl

Specified by:
put in interface ICacheService

remove

public Serializable remove(String key)
Description copied from interface: ICacheService
Remove an item from cache service by key

Specified by:
remove in interface ICacheService
Returns:
the value associated with the key

clear

public void clear()
Description copied from interface: ICacheService
Remove all cached items

Specified by:
clear in interface ICacheService

get

public Serializable get(String key)
Description copied from interface: ICacheService
Return an item from the cache service by key

Specified by:
get in interface ICacheService
Returns:
the value associated with the key

contains

public boolean contains(String key)
Description copied from interface: ICacheService
Check if the cache contains key

Specified by:
contains in interface ICacheService
Returns:
true if key is found in the cache

setDefaultTTL

public void setDefaultTTL(int ttl)
Description copied from interface: ICacheService
Set default ttl value which will be used if user pass 0 as ttl or not specified ttl

Specified by:
setDefaultTTL in interface ICacheService

shutdown

public void shutdown()
Description copied from interface: ICacheService
Shutdown the cache service

Specified by:
shutdown in interface ICacheService

startup

public void startup()
Description copied from interface: ICacheService
Restart the cache service after shutdown

Note, by default the cache service should be started after initialized

Specified by:
startup in interface ICacheService

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 2013. All Rights Reserved.