ca.uhn.cache.internal.impl
Class HibernateChunkStore

java.lang.Object
  extended byorg.springframework.orm.hibernate.support.HibernateDaoSupport
      extended byca.uhn.cache.internal.impl.HibernateChunkStore
All Implemented Interfaces:
IChunkPurger, IChunkStore, org.springframework.beans.factory.InitializingBean

public class HibernateChunkStore
extends org.springframework.orm.hibernate.support.HibernateDaoSupport
implements IChunkStore, IChunkPurger, org.springframework.beans.factory.InitializingBean

Hibernate-based implementation of IChunkStore

Version:
$Revision: 1.1 $ updated on $Date: 2005/01/24 22:54:04 $ by $Author: bryan_tripp $
Author:
Alexei Guevara

Field Summary
 
Fields inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
logger
 
Constructor Summary
HibernateChunkStore(IStaleChunkRule theStaleChunkRule)
          Constructor.
 
Method Summary
 IChunk get(IQuery theQuery)
           
 long getLowestVogueness()
          
 int getNumCachedItems()
          
 IStaleChunkRule getStaleChunkRule()
          
 IChunkIterator getStaleChunks()
          Implementation hint: to avoid doing a calculation during the query, store chunk with its expiry time, not its max age, and implement this method as "select chunks where expiry time earlier than now".
 IChunkIterator getUnusedChunks(long theVoguenessThreshold)
          Returns chunks that have not been accessed recently. Specifically, those for which vogueness < theVoguenessThreshold. Recall from IUnusedChunkRule that vogueness = last access time + modifier. Implementation hint: to avoid doing a calculation during the query, store the modified version of last access time, and implement this method as "select chunks where mod_last_access earlier than theMaxAccessTime".
 IChunk put(IQuery theQuery, VolatilityEnum theVolatility, CacheReasonEnum[] theReasons)
          Places a IChunk corresponding to the specified IQuery in this IChunkStore.
 IChunk remove(IQuery theQuery)
          Removes the mapping for this query from this IChunkStore if it is present
 
Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
afterPropertiesSet, closeSessionIfNecessary, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, initDao, setHibernateTemplate, setSessionFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
 

Constructor Detail

HibernateChunkStore

public HibernateChunkStore(IStaleChunkRule theStaleChunkRule)
Constructor.

Parameters:
theStaleChunkRule - The rule to decide when the chunks will become stale.
Method Detail

get

public IChunk get(IQuery theQuery)
Specified by:
get in interface IChunkStore
Parameters:
theQuery - The specified query.
Returns:
The value to which this IChunkStore maps the specified query, or null if the IChunkStore contains no mapping for the query.

put

public IChunk put(IQuery theQuery,
                  VolatilityEnum theVolatility,
                  CacheReasonEnum[] theReasons)
Places a IChunk corresponding to the specified IQuery in this IChunkStore. If the IChunkStore previously contained a mapping for this query, the value is replaced by a new IChunk with the new volatility and reasons.

Specified by:
put in interface IChunkStore
Parameters:
theQuery - Query with which the chunk is to be associated.
theVolatility - The volatility that will decide the length of stay in the cache. If there is a mapping for this query currently in the cache, this will replace the old value.
theReasons - The reasons that this chunk was cached. If there is a mapping for this query currently in the cache, this will be appended to the old value.
Returns:
Previous value associated with specified query, or null if there was no mapping for the query.

remove

public IChunk remove(IQuery theQuery)
Removes the mapping for this query from this IChunkStore if it is present

Specified by:
remove in interface IChunkStore
Parameters:
theQuery - Query whose mapping is to be removed from the IChunkStore.
Returns:
Previous value associated with specified query, or null if there was no mapping for the query.

getUnusedChunks

public IChunkIterator getUnusedChunks(long theVoguenessThreshold)
Returns chunks that have not been accessed recently. Specifically, those for which vogueness < theVoguenessThreshold. Recall from IUnusedChunkRule that vogueness = last access time + modifier. Implementation hint: to avoid doing a calculation during the query, store the modified version of last access time, and implement this method as "select chunks where mod_last_access earlier than theMaxAccessTime".

Specified by:
getUnusedChunks in interface IChunkPurger
Parameters:
theVoguenessThreshold - chunks that have not been accessed since this time (accounting for modifier) are to be returned
Returns:
chunks for which the modified access time is earlier than theMaxAccessTime

getStaleChunks

public IChunkIterator getStaleChunks()
Implementation hint: to avoid doing a calculation during the query, store chunk with its expiry time, not its max age, and implement this method as "select chunks where expiry time earlier than now".

Specified by:
getStaleChunks in interface IChunkPurger
Returns:
chunks that have been in the cache longer than their maximum ages.

getLowestVogueness

public long getLowestVogueness()

Specified by:
getLowestVogueness in interface IChunkPurger
Returns:
lowest vogueness of all chunks (based on the time at which the least recently used chunk was accessed; see IUnusedChunkRule)

getNumCachedItems

public int getNumCachedItems()

Specified by:
getNumCachedItems in interface IChunkPurger
Returns:
the number of records currently stored by the cache

getStaleChunkRule

public IStaleChunkRule getStaleChunkRule()

Specified by:
getStaleChunkRule in interface IChunkStore
Returns:
Returns the rule used to determine when chunks will expire.


Copyright © 2004-2005 University Health Network. All Rights Reserved.