org.apache.cocoon.caching
Class SimpleCache

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.caching.impl.CacheImpl
          extended byorg.apache.cocoon.caching.SimpleCache
All Implemented Interfaces:
Cache, Disposable, LogEnabled, Parameterizable, Serviceable, ThreadSafe

public class SimpleCache
extends CacheImpl

This cache implementation is an extension to the default cache implementation. If a response is not found in the cache or is invalid, it also checks the file system for a cached response. This allows to update the cache information by running batch processes.

Since:
2.1.1
Version:
CVS $Id: SimpleCache.java 30941 2004-07-29 19:56:58Z vgritsenko $
Author:
Carsten Ziegeler

Field Summary
protected  String baseDirectory
          The base directory
protected  Map locks
           
 
Fields inherited from class org.apache.cocoon.caching.impl.CacheImpl
manager, store
 
Fields inherited from interface org.apache.cocoon.caching.Cache
ROLE
 
Constructor Summary
SimpleCache()
           
 
Method Summary
 void clear()
          clear cache of all cached responses
 boolean containsKey(Serializable key)
          See if a response is cached under this key
protected  byte[] get(File file)
          Get the content from a file
 CachedResponse get(Serializable key)
          Get a cached response.
protected  File getFile(Serializable key)
          Get the filename
 void parameterize(Parameters parameters)
           
 void remove(Serializable key)
          Remove a cached response.
protected  void store(File file, byte[] content)
          store the content in a file
 void store(Serializable key, CachedResponse response)
          Store a cached response
 
Methods inherited from class org.apache.cocoon.caching.impl.CacheImpl
dispose, service
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseDirectory

protected String baseDirectory
The base directory


locks

protected Map locks
Constructor Detail

SimpleCache

public SimpleCache()
Method Detail

parameterize

public void parameterize(Parameters parameters)
                  throws ParameterException
Specified by:
parameterize in interface Parameterizable
Overrides:
parameterize in class CacheImpl
Throws:
ParameterException

getFile

protected File getFile(Serializable key)
Get the filename


clear

public void clear()
Description copied from class: CacheImpl
clear cache of all cached responses

Specified by:
clear in interface Cache
Overrides:
clear in class CacheImpl

containsKey

public boolean containsKey(Serializable key)
Description copied from class: CacheImpl
See if a response is cached under this key

Specified by:
containsKey in interface Cache
Overrides:
containsKey in class CacheImpl

get

public CachedResponse get(Serializable key)
Description copied from class: CacheImpl
Get a cached response. If it is not available null is returned.

Specified by:
get in interface Cache
Overrides:
get in class CacheImpl
Parameters:
key - the key used by the caching algorithm to identify the request

remove

public void remove(Serializable key)
Description copied from class: CacheImpl
Remove a cached response. If it is not available no operation is performed.

Specified by:
remove in interface Cache
Overrides:
remove in class CacheImpl
Parameters:
key - the key used by the caching algorithm to identify the request

store

public void store(Serializable key,
                  CachedResponse response)
           throws ProcessingException
Description copied from class: CacheImpl
Store a cached response

Specified by:
store in interface Cache
Overrides:
store in class CacheImpl
Parameters:
key - the key used by the caching algorithm to identify the request
response - the cached response
Throws:
ProcessingException

store

protected void store(File file,
                     byte[] content)
store the content in a file


get

protected byte[] get(File file)
Get the content from a file



Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.