diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java index 5c8b9b14f4ec1d8ac1d2366aa046b4ea5c17fe3f..fd497701e41a4cf67531cacd0b112accf5c2c076 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java @@ -64,10 +64,6 @@ public class XWikiCacheStore implements XWikiCacheStoreInterface, EventListener private Cache<Boolean> pageExistCache; - private int cacheCapacity = 500; - - private int pageExistCacheCapacity = 10000; - /** * Used to know if a received event is a local or remote one. */ @@ -105,34 +101,12 @@ public List<Event> getEvents() new WikiDeletedEvent()); } - // FIXME: init cache only at init and when asked for it instead of lazily in each method - - public void maybeInitCache(XWikiContext context) throws XWikiException + public void initCache(XWikiContext context) throws XWikiException { - if ((this.cache == null) || (this.pageExistCache == null)) { - initCache(context); - } - } + int cacheCapacity = (int) context.getWiki().ParamAsLong("xwiki.store.cache.capacity", 500); + int pageExistCacheCapacity = (int) context.getWiki().ParamAsLong("xwiki.store.cache.pageexistcapacity", 10000); - public synchronized void initCache(XWikiContext context) throws XWikiException - { - if ((this.cache == null) || (this.pageExistCache == null)) { - try { - String capacity = context.getWiki().Param("xwiki.store.cache.capacity"); - if (capacity != null) { - this.cacheCapacity = Integer.parseInt(capacity); - } - } catch (Exception e) { - } - try { - String capacity = context.getWiki().Param("xwiki.store.cache.pageexistcapacity"); - if (capacity != null) { - this.pageExistCacheCapacity = Integer.parseInt(capacity); - } - } catch (Exception e) { - } - initCache(this.cacheCapacity, this.pageExistCacheCapacity, context); - } + initCache(cacheCapacity, pageExistCacheCapacity, context); } @Override @@ -179,9 +153,6 @@ public void saveXWikiDoc(XWikiDocument doc, XWikiContext context, boolean bTrans doc.setStore(this.store); - // Make sure cache is initialized - maybeInitCache(context); - // We need to flush so that caches // on the cluster are informed about the change String key = getKey(doc, context); @@ -284,11 +255,6 @@ public XWikiDocument loadXWikiDoc(XWikiDocument doc, XWikiContext context) throw // Calculate the cache key String key = getKey(doc, context); - LOGGER.debug("Cache: begin for doc {} in cache", key); - - // Make sure cache is initialized - maybeInitCache(context); - LOGGER.debug("Cache: Trying to get doc {} from cache", key); XWikiDocument cachedoc; @@ -351,9 +317,6 @@ public void deleteXWikiDoc(XWikiDocument doc, XWikiContext context) throws XWiki this.store.deleteXWikiDoc(doc, context); - // Make sure cache is initialized - maybeInitCache(context); - getCache().remove(key); getPageExistCache().remove(key); getPageExistCache().set(key, Boolean.FALSE); @@ -663,9 +626,6 @@ public boolean exists(XWikiDocument doc, XWikiContext context) throws XWikiExcep // Calculate the cache key String key = getKey(doc, context); - // Make sure cache is initialized - maybeInitCache(context); - try { Boolean result = getPageExistCache().get(key);