lumis.portal.cache
Class PortalCache<T>

Package class diagram package PortalCache
java.lang.Object
  extended by lumis.portal.cache.PortalCache<T>
Type Parameters:
T - Type of the objects that will be cached.

@StableMinor(version="5.5",
             sinceVersion="4.0")
public class PortalCache<T>
extends Object

Memory cache for portal objects. The identifier of a portal cache instance (given in the constructor) must be unique.

Since:
4.0.0

Field Summary
static int MAX_AGE_INFINITE
          Value that indicates that there is no maximum age for entries in this cache.
 
Constructor Summary
PortalCache(String cacheId)
           
PortalCache(String cacheId, boolean autoClone)
           
PortalCache(String cacheId, ICacheDataProvider<T> defaultCacheDataProvider)
          Creates a portal cache instance with the specified identifier and cache data provider.
 
Method Summary
 void clear()
           
 void clear(ITransaction transaction)
          Clears the cache and disables it until the given transaction ends.
static void clearAll()
           
 void destroy()
           
 T fetch(String key)
          Obtain the value associated with the specified key.
 T fetch(String key, ICacheDataProvider<T> cacheDataProvider)
          Obtain the value associated with the specified key.
 T get(String key)
           
static PortalCache getCache(String cacheId)
           
static Collection<String> getCacheIds()
           
 int getCapacity()
          Returns the current capacity of this portal cache.
 String getId()
           
 int getMaxAgeSeconds()
          Returns the current maximum age for entries in this cache.
 int getSize()
          Returns the number of entries currently stored in this cache.
 ICacheStatistics getStatistics()
           
 void put(String key, T value)
           
 void remove(String key)
           
 void remove(String key, ITransaction transaction)
          Removes an entry from the cache now and after the given transaction ends.
 void setCapacity(int newCapacity)
          Sets the capacity for this portal cache.
 void setMaxAgeSeconds(int maxAgeSeconds)
          Sets the maximum age for entries in this cache.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_AGE_INFINITE

public static final int MAX_AGE_INFINITE
Value that indicates that there is no maximum age for entries in this cache.

Since:
4.2.1
See Also:
Constant Field Values
Constructor Detail

PortalCache

public PortalCache(String cacheId)

PortalCache

public PortalCache(String cacheId,
                   ICacheDataProvider<T> defaultCacheDataProvider)
Creates a portal cache instance with the specified identifier and cache data provider.

Parameters:
cacheId - the cache identifier.
defaultCacheDataProvider - the default cache data provider for this cache instance.
Since:
4.2.0

PortalCache

public PortalCache(String cacheId,
                   boolean autoClone)
Method Detail

clearAll

public static void clearAll()

getId

public String getId()

toString

public String toString()
Overrides:
toString in class Object

getMaxAgeSeconds

public int getMaxAgeSeconds()
Returns the current maximum age for entries in this cache.

Returns:
the maximum age in seconds, or MAX_AGE_INFINITE to indicate there is no maximum age.
Since:
4.2.1

setMaxAgeSeconds

public void setMaxAgeSeconds(int maxAgeSeconds)
Sets the maximum age for entries in this cache. When the specified time has passed since an entry was added, it will no longer be returned by this cache.

Parameters:
maxAgeSeconds - the maximum age in seconds, or MAX_AGE_INFINITE to indicate there is no maximum age.
Since:
4.2.1

get

public T get(String key)

fetch

public T fetch(String key)
        throws PortalException
Obtain the value associated with the specified key. If the value is not available in the cache, the ICacheDataProvider of this PortalCache is used to read the value, and it is cached.

Parameters:
key - the key.
Returns:
the value.
Throws:
UnsupportedOperationException - if there is no ICacheDataProvider specified for this cache instance.
PortalException - if ICacheDataProvider.loadData(String) throws it.
RuntimeException - any runtime exception thrown by ICacheDataProvider.loadData(String) is thrown by this method.
Since:
4.2.0

fetch

public T fetch(String key,
               ICacheDataProvider<T> cacheDataProvider)
        throws PortalException
Obtain the value associated with the specified key.

Parameters:
key - the key.
cacheDataProvider - the data provider used if the value is not currently available in the cache.
Returns:
the value.
Throws:
PortalException - if ICacheDataProvider.loadData(String) throws it.
RuntimeException - any runtime exception thrown by ICacheDataProvider.loadData(String) is thrown by this method.
Since:
4.2.0

put

public void put(String key,
                T value)

remove

public void remove(String key)

remove

public void remove(String key,
                   ITransaction transaction)
            throws PortalException
Removes an entry from the cache now and after the given transaction ends. The entry is not stored in the cache until the transaction ends (commits or rollsback).

Parameters:
key - the entry key.
transaction - the transaction.
Throws:
PortalException
Since:
4.0.10

clear

public void clear()

clear

public void clear(ITransaction transaction)
           throws PortalException
Clears the cache and disables it until the given transaction ends. No entry is stored in the cache until the transaction ends (commits or rollsback).

Parameters:
transaction - the transaction.
Throws:
PortalException
Since:
4.1.0

getSize

public int getSize()
Returns the number of entries currently stored in this cache.

Returns:
the number of entries currently stored in this cache.
Since:
4.0.11

getCapacity

public int getCapacity()
Returns the current capacity of this portal cache.

Returns:
the current capacity of this portal cache, in number of entries.
Since:
4.0.11

setCapacity

public void setCapacity(int newCapacity)
Sets the capacity for this portal cache.

Since:
4.0.11

destroy

public void destroy()

getStatistics

public ICacheStatistics getStatistics()

getCache

public static PortalCache getCache(String cacheId)

getCacheIds

public static Collection<String> getCacheIds()


Lumisportal  5.5.0.091130 - Copyright © 2001-2007, Lumis. All Rights Reserved.