atg.search.cache
Class SearchQueryCache

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.search.cache.SearchQueryCache
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class SearchQueryCache
extends GenericService

This class is used to create components for storing performed queries (request/response) and documents in a cache.

Search information is not stored in persistent store and only available as a live value while getting response from Search Engine (QueryRequest and QueryRequest.Response objects). That is why it is required to place it in some kind of session history cache, so such information can be accessible later.

The cache is designed as a Least Recently Used (LRU) cache, so when new object is arrived and cache is full, new object will replace oldest one. All items are being expired from the cache only when it is full. The administrator is able to tune both the number of request/response objects in a history cache(via queryCount property) and the number of documents that should be cached per search(via documentCount property). It is also possible to specify -1 as unlimited size for cache.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
SearchQueryCache()
           
 
Method Summary
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 atg.search.cache.CacheElement get(java.lang.String pQueryId)
          Returns CacheElement object (request/response) from the cache by query Id
 Document getDocument(java.lang.String pUrl)
          Returns document object from the cache by URL
 Document getDocumentById(java.lang.String pId)
          Returns document object from the cache by id
 atg.search.cache.SearchDocumentCache getDocumentCache()
          Returns documentCache property.
 int getDocumentCount()
          Returns property documentCount.
 int getQueryCount()
          Returns property queryCount.
 void put(java.lang.String pQueryId, atg.search.cache.CacheElement pCacheElement)
          Puts CacheElement object (request/response) into the cache by query Id
 java.lang.String putDocument(java.lang.String pQueryId, Document pDocument)
          Puts document object into the cache
 void setDocumentCache(atg.search.cache.SearchDocumentCache pDocumentCache)
          Sets documentCache property.
 void setDocumentCount(int pDocumentCount)
          Sets documentCount property.
 void setQueryCount(int pQueryCount)
          Sets property queryCount.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

SearchQueryCache

public SearchQueryCache()
Method Detail

getQueryCount

public int getQueryCount()
Returns property queryCount. This property contains count of CacheElement items which we are storing at LRU cache.

Returns:
queryCount property

setQueryCount

public void setQueryCount(int pQueryCount)
Sets property queryCount. This property contains count of CacheElement items which we are storing at LRU cache.

Parameters:
pQueryCount - New value for queryCount property

getDocumentCount

public int getDocumentCount()
Returns property documentCount. This property contains count of document items which we are storing at LRU cache per each search.

Returns:
documentCount property

setDocumentCount

public void setDocumentCount(int pDocumentCount)
Sets documentCount property. This property contains count of document items which we are storing at LRU cache per each search.

Parameters:
pDocumentCount - New value for documentCount property

getDocumentCache

public atg.search.cache.SearchDocumentCache getDocumentCache()
Returns documentCache property. This property contains reference to the SearchDocumentCache component used for storing documents.

Returns:
documentCache property

setDocumentCache

public void setDocumentCache(atg.search.cache.SearchDocumentCache pDocumentCache)
Sets documentCache property. This property contains reference to the SearchDocumentCache component used for storing documents.

Parameters:
pDocumentCache - New value for documentCache property

put

public void put(java.lang.String pQueryId,
                atg.search.cache.CacheElement pCacheElement)
Puts CacheElement object (request/response) into the cache by query Id

Parameters:
pQueryId - Query Id
pCacheElement - CacheElement object

get

public atg.search.cache.CacheElement get(java.lang.String pQueryId)
Returns CacheElement object (request/response) from the cache by query Id

Parameters:
pQueryId - Query Id
Returns:
CacheElement object

putDocument

public java.lang.String putDocument(java.lang.String pQueryId,
                                    Document pDocument)
Puts document object into the cache

Parameters:
pQueryId - Query Id
pDocument - document object
Returns:
Id value for document

getDocument

public Document getDocument(java.lang.String pUrl)
Returns document object from the cache by URL

Parameters:
pUrl - document URL
Returns:
document object

getDocumentById

public Document getDocumentById(java.lang.String pId)
Returns document object from the cache by id

Parameters:
pId - document Id
Returns:
document object

doStartService

public void doStartService()
                    throws ServiceException
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. This method should start any processes required to run the service.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up