org.apache.cocoon.pipeline.caching
Interface Cache

All Known Implementing Classes:
AbstractCache, SimpleCache

public interface Cache


Method Summary
 void clear()
          Removes all data coneined in this Cache
 CacheValue get(CacheKey cacheKey)
          Retrieves the CacheValue previously stored using the given cacheKey.
 CacheValue get(CacheKey cacheKey, boolean includeInvalid)
          Retrieves the CacheValue previously stored using the given cacheKey.
 Set<CacheKey> keySet()
          Returns Set of CacheKey contained in this Cache
 void put(CacheKey cacheKey, CacheValue cacheValue)
          Stores the given cacheValue at the given cacheKey.
 boolean remove(CacheKey cacheKey)
          Removes that CacheKey from this Cache.
 

Method Detail

put

void put(CacheKey cacheKey,
         CacheValue cacheValue)
Stores the given cacheValue at the given cacheKey.

If this cache already contains the given cacheKey it will be replaced.
If two CacheKeys represent the same data is ultimately depending on the implementation, but usually relies on the equals an/or hashcode methods.

Parameters:
cacheKey - The CacheKey to be used for storing.
cacheValue - The CacheValue to be stored.

get

CacheValue get(CacheKey cacheKey)
Retrieves the CacheValue previously stored using the given cacheKey.
If the cacheKey is not stored in this Cache this method will return null.

Furthermore the Cache will check if the stored CacheValue is still valid (using the CacheValue.isValid(CacheKey) method). If the CacheValue is considered to be invalid this method will return null as well (indicating that no valid CacheValue is available).

To retrieve CacheValues even if they are invalid, use the get(CacheKey, boolean) method.

Parameters:
cacheKey - The CacheKey defining which CacheValue to retrieve.
Returns:
The previously stored CacheValue or null if no or no valid CacheValue is stored at the given cacheValue.

get

CacheValue get(CacheKey cacheKey,
               boolean includeInvalid)
Retrieves the CacheValue previously stored using the given cacheKey.
If the cacheKey is not stored in this Cache this method will return null.

This method will omit the check for validity if includeInvalid is true (i.e. the returned CacheValue might be invalid in this case).

Parameters:
cacheKey - The CacheKey defining which CacheValue to retrieve.
includeInvalid - Defines whether invalid CacheValue should be returned or not. Using true will also return invalid CacheValue. Using false will yield the same results as get(CacheKey).
Returns:
The previously stored CacheValue or null if and only if no CacheValue is stored at the given cacheValue.

keySet

Set<CacheKey> keySet()
Returns Set of CacheKey contained in this Cache

Returns:
a set CacheKey contained in this Cache

remove

boolean remove(CacheKey cacheKey)
Removes that CacheKey from this Cache.

Parameters:
cacheKey -

clear

void clear()
Removes all data coneined in this Cache



Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.