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 fd497701e41a4cf67531cacd0b112accf5c2c076..0710b5a26e6f5b15470bbe38b0ed0bc7fd21642f 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 @@ -102,32 +102,31 @@ public List<Event> getEvents() } public void initCache(XWikiContext context) throws XWikiException - { - int cacheCapacity = (int) context.getWiki().ParamAsLong("xwiki.store.cache.capacity", 500); - int pageExistCacheCapacity = (int) context.getWiki().ParamAsLong("xwiki.store.cache.pageexistcapacity", 10000); - - initCache(cacheCapacity, pageExistCacheCapacity, context); - } - - @Override - public void initCache(int capacity, int pageExistCacheCapacity, XWikiContext context) throws XWikiException { CacheManager cacheManager = Utils.getComponent(CacheManager.class); try { - Cache<XWikiDocument> pageCache = - cacheManager.createNewCache(new LRUCacheConfiguration("xwiki.store.pagecache", capacity)); - setCache(pageCache); + int pageCacheCapacity = (int) context.getWiki().ParamAsLong("xwiki.store.cache.capacity", 500); + this.cache = + cacheManager.createNewCache(new LRUCacheConfiguration("xwiki.store.pagecache", pageCacheCapacity)); - Cache<Boolean> pageExistcache = cacheManager + int pageExistCacheCapacity = + (int) context.getWiki().ParamAsLong("xwiki.store.cache.pageexistcapacity", 10000); + this.pageExistCache = cacheManager .createNewCache(new LRUCacheConfiguration("xwiki.store.pageexistcache", pageExistCacheCapacity)); - setPageExistCache(pageExistcache); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to initialize cache", e); } } + @Deprecated + @Override + public void initCache(int capacity, int pageExistCacheCapacity, XWikiContext context) throws XWikiException + { + // Do nothing + } + @Override public XWikiStoreInterface getStore() { @@ -170,15 +169,8 @@ public void saveXWikiDoc(XWikiDocument doc, XWikiContext context, boolean bTrans @Override public void flushCache() { - if (this.cache != null) { - this.cache.dispose(); - this.cache = null; - } - - if (this.pageExistCache != null) { - this.pageExistCache.dispose(); - this.pageExistCache = null; - } + getCache().removeAll(); + getPageExistCache().removeAll(); } @Override diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/store/XWikiCacheStoreInterface.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/store/XWikiCacheStoreInterface.java index 83424757429cfd2bb704d4a25d068754318c38f8..3e6dd6874734dfbcc90f1c8f10c54829ec7885b5 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/store/XWikiCacheStoreInterface.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/store/XWikiCacheStoreInterface.java @@ -30,5 +30,10 @@ public interface XWikiCacheStoreInterface extends XWikiStoreInterface void flushCache(); + /** + * @deprecated since 8.3. It does not make much sense to make this method public and it was not really doing + * anything for a very long time in practice (since Infinispan is the default cache inmplementation) + */ + @Deprecated void initCache(int capacity, int pageExistCapacity, XWikiContext context) throws XWikiException; }