public class DefaultCacheKeyGenerator extends Object implements CacheKeyGenerator
| Constructor and Description |
|---|
DefaultCacheKeyGenerator() |
| Modifier and Type | Method and Description |
|---|---|
String |
generate(Resource resource,
RenderContext renderContext,
Properties properties)
Generates the output cache key based on the provided data.
|
Properties |
getAttributesForKey(RenderContext renderContext,
Resource resource)
Get all cache attributes that need to be applied on this fragment and that will impact key generation.
|
CacheKeyPartGenerator |
getPartGenerator(String field)
Return the cache key part generator corresponding to the given field
|
Map<String,String> |
parse(String key)
Parses the specified key into separate fields.
|
Map<String,Object> |
prepareContextForContentGeneration(Map<String,String> keyParts,
Resource resource,
RenderContext renderContext)
Before generating a sub-fragment during aggregation, this function will be called to modify the render context.
|
void |
registerPartGenerator(CacheKeyPartGenerator partGenerator)
Register a part generator, if part generator already exist with that key it will be replaced
|
String |
replaceField(String key,
String fieldName,
String newValue)
Deprecated.
|
String |
replacePlaceholdersInCacheKey(RenderContext renderContext,
String key)
Transform the fragment key into the final key used for caching the fragment
|
void |
restoreContextAfterContentGeneration(Map<String,String> keyParts,
Resource resource,
RenderContext renderContext,
Map<String,Object> original)
After generating a sub-fragment during aggregation, this function will be called to restore the render context.
|
void |
setPartGenerators(List<CacheKeyPartGenerator> partGenerators) |
void |
unregisterPartGenerator(CacheKeyPartGenerator partGenerator)
Unregister a part generator
|
public void registerPartGenerator(CacheKeyPartGenerator partGenerator)
partGenerator - the part generator to be registeredpublic void unregisterPartGenerator(CacheKeyPartGenerator partGenerator)
partGenerator - the part generator to be unregisteredpublic String generate(Resource resource, RenderContext renderContext, Properties properties)
CacheKeyGeneratorgenerate in interface CacheKeyGeneratorresource - the current resource being renderedrenderContext - the current rendering contextproperties - Fragment propertiespublic Map<String,String> parse(String key)
CacheKeyGeneratorparse in interface CacheKeyGeneratorkey - the cache key to be decomposed@Deprecated public String replaceField(String key, String fieldName, String newValue)
replaceField in interface CacheKeyGeneratorpublic CacheKeyPartGenerator getPartGenerator(String field)
CacheKeyGeneratorgetPartGenerator in interface CacheKeyGeneratorfield - the given fieldpublic String replacePlaceholdersInCacheKey(RenderContext renderContext, String key)
CacheKeyGeneratorreplacePlaceholdersInCacheKey in interface CacheKeyGeneratorrenderContext - the current render contextkey - the key to be transformedpublic Map<String,Object> prepareContextForContentGeneration(Map<String,String> keyParts, Resource resource, RenderContext renderContext)
CacheKeyGeneratorprepareContextForContentGeneration in interface CacheKeyGeneratorkeyParts - The fragment key parsed, typically a map returned by the parse methodresource - The current rendered resourcerenderContext - The current renderContextpublic void restoreContextAfterContentGeneration(Map<String,String> keyParts, Resource resource, RenderContext renderContext, Map<String,Object> original)
CacheKeyGeneratorrestoreContextAfterContentGeneration in interface CacheKeyGeneratorkeyParts - The fragment key parsed, typically a map returned by the parse methodresource - The current rendered resourcerenderContext - The current renderContextoriginal - The map previously retrieved via prepareContextForContentGeneration() invocationpublic Properties getAttributesForKey(RenderContext renderContext, Resource resource) throws javax.jcr.RepositoryException
getAttributesForKey in interface CacheKeyGeneratorjavax.jcr.RepositoryExceptionpublic void setPartGenerators(List<CacheKeyPartGenerator> partGenerators)
Copyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.