info.magnolia.module.cache
Interface CachePolicy

All Known Implementing Classes:
Default, Never

public interface CachePolicy

The CachePolicy determines is a requested page should be cached, retrieved from the cache or not cached at all. It is called for every request and should thus also take care of any expiration policy - i.e if the page should be re-cached. The CacheFilter (or any other client component) can determine its behaviour based on the return CachePolicyResult, which holds both the behaviour to take and the cache key to use when appropriate.

Version:
$Revision: $ ($Author: $)
Author:
gjoseph

Method Summary
 void persistCacheKey(String repo, String uuid, Object key)
          Persists mapping between uuid and cache key in case the given cache policy implementation cares about such details.
 Object[] removeCacheKeys(String uuid, String repository)
          Returns cache keys for the given item or null if such keys can't be obtained or policy doesn't want to share it.
 Object retrieveCacheKey(AggregationState aggregationState)
          Returns cache key for the given item or null if such key can't be obtained or policy doesn't want to share it.
 Object[] retrieveCacheKeys(String uuid, String repository)
          Returns cache keys for the given item or null if such keys can't be obtained or policy doesn't want to share it.
 CachePolicyResult shouldCache(Cache cache, AggregationState aggregationState, FlushPolicy flushPolicy)
          Implementations can chose whether to cache or not - but note that the aggregationState might not be completely populated.
 

Method Detail

shouldCache

CachePolicyResult shouldCache(Cache cache,
                              AggregationState aggregationState,
                              FlushPolicy flushPolicy)
Implementations can chose whether to cache or not - but note that the aggregationState might not be completely populated. Every request should be cacheable, not only those processed through Magnolia's RenderingFilter.


retrieveCacheKey

Object retrieveCacheKey(AggregationState aggregationState)
Returns cache key for the given item or null if such key can't be obtained or policy doesn't want to share it. When using aggregationState, key is expected to be composed with aggregated request in mind and policy has to choose only one such key denoting item to return to the client, if such an item indeed exists and can be served. When not existing key might be used to store the cache entry. Since only one version of the content can be streamed back to the client, it makes sense to create only one cache entry for the such a key as well.


retrieveCacheKeys

Object[] retrieveCacheKeys(String uuid,
                           String repository)
Returns cache keys for the given item or null if such keys can't be obtained or policy doesn't want to share it. Since in this case uuid is used to retrieve the cache key, it is quite possible that multiple different representations of the content denoted by uuid exist and all such keys should be returned leaving it up to requesting object to deal with such a multiplicity. Please note that returned keys might not be necessary multiple representations of the content denoted by provided uuid, but also quite possibly all the content deemed related or partially used to construct any of the returned cache keys.


persistCacheKey

void persistCacheKey(String repo,
                     String uuid,
                     Object key)
Persists mapping between uuid and cache key in case the given cache policy implementation cares about such details.


removeCacheKeys

Object[] removeCacheKeys(String uuid,
                         String repository)
Returns cache keys for the given item or null if such keys can't be obtained or policy doesn't want to share it. Since in this case uuid is used to retrieve the cache key, it is quite possible that multiple different representations of the content denoted by uuid exist and all such keys should be returned leaving it up to requesting object to deal with such a multiplicity. Please note that returned keys might not be necessary multiple representations of the content denoted by provided uuid, but also quite possibly all the content deemed related or partially used to construct any of the returned cache keys. At the call to this method, cache policy should not only return the keys associated with the uuid, but also remove all returned uuid-cahce key mappings.



Copyright © 2003-2013 Magnolia International Ltd.. All Rights Reserved.