Index: main/plugin-web/src/org/ametys/web/cache/pageelement/PageElementCache.java
===================================================================
--- main/plugin-web/src/org/ametys/web/cache/pageelement/PageElementCache.java (revision 33486)
+++ main/plugin-web/src/org/ametys/web/cache/pageelement/PageElementCache.java (working copy)
@@ -23,6 +23,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
@@ -38,7 +39,7 @@
* Cache the page elements renderings.
* This class handles several caches, one per site and per JCR workspace.
*/
-public class PageElementCache extends AbstractLogEnabled implements Component, Contextualizable, Disposable
+public class PageElementCache extends AbstractLogEnabled implements Component, Contextualizable, Disposable, Initializable
{
/** Avalon role. */
public static final String ROLE = PageElementCache.class.getName();
@@ -49,6 +50,9 @@
// Map>>>>>
private Map>>>>> _cache = new HashMap<>();
+ // Cache>>
+ //private Cache>> _cache;
+
// Map>>
private Map>> _currentHitCount = new HashMap<>();
@@ -66,6 +70,12 @@
_context = context;
}
+ @Override
+ public void initialize() throws Exception
+ {
+ //_cache = CacheBuilder.newBuilder().maximumSize(10).build();
+ }
+
/**
* Add a content in the cache.
* @param workspace the current JCR workspace.
@@ -579,4 +589,38 @@
}
}
+ private static class CacheKey
+ {
+ String _workspace;
+ String _site;
+ String _pageElementType;
+ String _elementId;
+
+ CacheKey(String workspace, String site, String pageElementType, String elementId)
+ {
+ _workspace = workspace;
+ _site = site;
+ _pageElementType = pageElementType;
+ _elementId = elementId;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _workspace.hashCode() + _site.hashCode() + _pageElementType.hashCode() + _elementId.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof CacheKey))
+ {
+ return false;
+ }
+
+ CacheKey key = (CacheKey) obj;
+
+ return _workspace.equals(key._workspace) && _site.equals(key._site) && _pageElementType.equals(key._pageElementType) && _elementId.equals(key._elementId);
+ }
+ }
}