eXo Kernel :: Component :: Cache Service 2.5.0-Alpha4

org.exoplatform.services.cache
Interface ExoCache<K extends Serializable,V>

Type Parameters:
K - the type of keys maintained by this cache
V - the type of cached values
All Known Implementing Classes:
ConcurrentFIFOExoCache, FIFOExoCache, InvalidationExoCache, SimpleExoCache

public interface ExoCache<K extends Serializable,V>

Created by The eXo Platform SAS
A bare cache.

Author:
Tuan Nguyen

Method Summary
 void addCacheListener(CacheListener<? super K,? super V> listener)
          Add a listener.
 void clearCache()
          Clears the cache.
 V get(Serializable key)
          Performs a lookup operation.
 List<? extends V> getCachedObjects()
          Returns a list of cached object that are considered as valid when the method is called.
 int getCacheHit()
          Returns the number of time the cache was queried and a valid entry was returned.
 int getCacheMiss()
          Returns the number of time the cache was queried and no entry was returned.
 int getCacheSize()
          Returns the number of entries in the cache.
 String getLabel()
          Returns the cache label
 long getLiveTime()
          Returns the maximum life time of an entry in the cache.
 int getMaxSize()
          Returns the maximum capacity of the cache.
 String getName()
          Returns the cache name
 boolean isLogEnabled()
           
 void put(K key, V value)
          Performs a put in the cache.
 void putMap(Map<? extends K,? extends V> objs)
          Performs a put of all the entries provided by the map argument.
 V remove(Serializable key)
          Removes an entry from the cache.
 List<? extends V> removeCachedObjects()
          Clears the cache and returns the list of cached object that are considered as valid when the method is called.
 void select(CachedObjectSelector<? super K,? super V> selector)
          Selects a subset of the cache.
 void setLabel(String s)
          Sets the cache label
 void setLiveTime(long period)
          Sets the maximum life time of an entry in the cache.
 void setLogEnabled(boolean b)
           
 void setMaxSize(int max)
          Sets the maximum capacity of the cache.
 void setName(String name)
          Sets the cache name.
 

Method Detail

getName

String getName()
Returns the cache name

Returns:
the cache name

setName

void setName(String name)
Sets the cache name.

Parameters:
name - the cache name

getLabel

String getLabel()
Returns the cache label

Returns:
the cache label

setLabel

void setLabel(String s)
Sets the cache label

Parameters:
s - the cache label

get

V get(Serializable key)
Performs a lookup operation.

Parameters:
key - the cache key
Returns:
the cached value which may be evaluated to null

remove

V remove(Serializable key)
         throws NullPointerException
Removes an entry from the cache.

Parameters:
key - the cache key
Returns:
the previously cached value or null if no entry existed or that entry value was evaluated to null
Throws:
NullPointerException - if the provided key is null

put

void put(K key,
         V value)
         throws NullPointerException
Performs a put in the cache.

Parameters:
key - the cache key
value - the cached value
Throws:
NullPointerException - if the key is null

putMap

void putMap(Map<? extends K,? extends V> objs)
            throws NullPointerException,
                   IllegalArgumentException
Performs a put of all the entries provided by the map argument.

Parameters:
objs - the objects to put
Throws:
NullPointerException - if the provided argument is null
IllegalArgumentException - if the provided map contains a null key

clearCache

void clearCache()
Clears the cache.


select

void select(CachedObjectSelector<? super K,? super V> selector)
            throws Exception
Selects a subset of the cache.

Parameters:
selector - the selector
Throws:
Exception - any exception

getCacheSize

int getCacheSize()
Returns the number of entries in the cache.

Returns:
the size of the cache

getMaxSize

int getMaxSize()
Returns the maximum capacity of the cache.

Returns:
the maximum capacity

setMaxSize

void setMaxSize(int max)
Sets the maximum capacity of the cache.

Parameters:
max - the maximum capacity

getLiveTime

long getLiveTime()
Returns the maximum life time of an entry in the cache. The life time is a value in seconds, a negative value means that the life time is infinite.

Returns:
the live time

setLiveTime

void setLiveTime(long period)
Sets the maximum life time of an entry in the cache.

Parameters:
period - the live time

getCacheHit

int getCacheHit()
Returns the number of time the cache was queried and a valid entry was returned.

Returns:
the cache hits

getCacheMiss

int getCacheMiss()
Returns the number of time the cache was queried and no entry was returned.

Returns:
the cache misses

getCachedObjects

List<? extends V> getCachedObjects()
                                   throws Exception
Returns a list of cached object that are considered as valid when the method is called. Any non valid object will not be returnted.

Returns:
the list of cached objects
Throws:
Exception - any exception

removeCachedObjects

List<? extends V> removeCachedObjects()
Clears the cache and returns the list of cached object that are considered as valid when the method is called. Any non valid object will not be returned.

Returns:
the list of cached objects
Throws:
Exception - any exception

addCacheListener

void addCacheListener(CacheListener<? super K,? super V> listener)
                      throws NullPointerException
Add a listener.

Parameters:
listener - the listener to add
Throws:
NullPointerException - if the listener is null

isLogEnabled

boolean isLogEnabled()

setLogEnabled

void setLogEnabled(boolean b)

eXo Kernel :: Component :: Cache Service 2.5.0-Alpha4

Copyright © 2014 eXo Platform SAS. All Rights Reserved.