|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.flex.CmsFlexCache
public class CmsFlexCache
This class implements the FlexCache.
The data structure used is a two-level hashtable. This is optimized for the structure of the keys that are used to describe the caching behaviour of the entries. The first hash-level is calculated from the resource name, i.e. the name of the resource as it is referred to in the VFS of OpenCms. The second hash-level is calculated from the cache-key of the resource, which also is a String representing the specifc variation of the cached entry.
A suffix [online] or [offline] is appended to te resource name to distinguish between the online and offline projects of OpenCms. Also, for support of JSP based workplace pages, a suffix [workplace] is appended. The same cached workplace pages are used both in the online and all offline projects.
Entries in the first level of the cache are of type CmsFlexCacheVariation, which is a sub-class of CmsFlexCache. This class is a simple data type that contains of a Map of CmsFlexCacheEntries, with variations - Strings as keys.
Here's a short summary of used terms:
I_CmsEventListener.EVENT_PUBLISH_PROJECT
or I_CmsEventListener.EVENT_CLEAR_CACHES
is caught.
CmsFlexCacheKey
,
CmsFlexCacheEntry
,
CmsLruCache
,
I_CmsLruCacheObject
Nested Class Summary | |
---|---|
static class |
CmsFlexCache.CmsFlexCacheVariation
A simple data container class for the FlexCache variations. |
Field Summary | |
---|---|
static java.lang.String |
CACHE_OFFLINESUFFIX
Suffix to append to online cache entries. |
static java.lang.String |
CACHE_ONLINESUFFIX
Suffix to append to online cache entries. |
static int |
CLEAR_ALL
Trigger for clearcache event: Clear complete cache. |
static int |
CLEAR_ENTRIES
Trigger for clearcache event: Clear only entries. |
static int |
CLEAR_OFFLINE_ALL
Trigger for clearcache event: Clear complete offine cache. |
static int |
CLEAR_OFFLINE_ENTRIES
Trigger for clearcache event: Clear only offline entries. |
static int |
CLEAR_ONLINE_ALL
Trigger for clearcache event: Clear complete online cache. |
static int |
CLEAR_ONLINE_ENTRIES
Trigger for clearcache event: Clear only online entries. |
static int |
INITIAL_CAPACITY_CACHE
Initial cache size, this should be a power of 2 because of the Java collections implementation. |
static int |
INITIAL_CAPACITY_VARIATIONS
Initial size for variation lists, should be a power of 2. |
protected CmsLruCache |
m_variationCache
The LRU cache to organize the cached entries. |
static java.lang.String |
REPOSITORY_OFFLINE
Offline repository constant. |
static java.lang.String |
REPOSITORY_ONLINE
Online repository constant. |
Constructor Summary | |
---|---|
CmsFlexCache(CmsFlexCacheConfiguration configuration)
Constructor for class CmsFlexCache. |
Method Summary | |
---|---|
boolean |
cacheOffline()
Indicates if offline project resources are cached. |
void |
cmsEvent(CmsEvent event)
Implements the CmsEvent interface, the FlexCache uses the events to clear itself in case a project is published. |
CmsFlexCacheKey |
getCachedKey(java.lang.String key,
CmsObject cms)
Returns the CmsFlexCacheKey data structure for a given key (i.e. resource name). |
java.util.Set |
getCachedResources(CmsObject cms)
Returns a set of all cached resource names. |
java.util.Set |
getCachedVariations(java.lang.String key,
CmsObject cms)
Returns all variations in the cache for a given resource name. |
CmsLruCache |
getEntryLruCache()
Returns the LRU cache where the CacheEntries are cached. |
boolean |
isEnabled()
Indicates if the cache is enabled (i.e. actually caching entries) or not. |
int |
keySize()
Returns the total number of cached resource keys. |
int |
size()
Returns the total number of entries in the cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CACHE_OFFLINESUFFIX
public static final java.lang.String CACHE_ONLINESUFFIX
public static final int CLEAR_ALL
public static final int CLEAR_ENTRIES
public static final int CLEAR_OFFLINE_ALL
public static final int CLEAR_OFFLINE_ENTRIES
public static final int CLEAR_ONLINE_ALL
public static final int CLEAR_ONLINE_ENTRIES
public static final int INITIAL_CAPACITY_CACHE
public static final int INITIAL_CAPACITY_VARIATIONS
public static final java.lang.String REPOSITORY_OFFLINE
public static final java.lang.String REPOSITORY_ONLINE
protected CmsLruCache m_variationCache
Constructor Detail |
---|
public CmsFlexCache(CmsFlexCacheConfiguration configuration)
The parameter "enabled" is used to control if the cache is actually on or off. Even if you don't need the cache, you still have to create an instance of it with enabled=false. This is because you need some of the FlexCache data structures for JSP inclusion buffering.
configuration
- the flex cache configurationMethod Detail |
---|
public boolean cacheOffline()
public void cmsEvent(CmsEvent event)
cmsEvent
in interface I_CmsEventListener
event
- CmsEvent that has occurredpublic CmsFlexCacheKey getCachedKey(java.lang.String key, CmsObject cms)
Useful if you want to show the cache key for a resources, like on the FlexCache administration page.
Only users with administrator permissions are allowed to perform this operation.
key
- the resource name for which to look up the variation forcms
- the CmsObject used for user authorization
public java.util.Set getCachedResources(CmsObject cms)
Only users with administrator permissions are allowed to perform this operation.
cms
- the CmsObject used for user authorization
public java.util.Set getCachedVariations(java.lang.String key, CmsObject cms)
Usefull if you want to show a list of all cached entry - variations, like on the FlexCache administration page.
Only users with administrator permissions are allowed to perform this operation.
key
- the resource name for which to look up the variations forcms
- the CmsObject used for user authorization
public CmsLruCache getEntryLruCache()
public boolean isEnabled()
public int keySize()
public int size()
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |