Skip to content
Snippets Groups Projects
Commit 1b228eab authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

XWIKI-13771: Make XWikiCacheStore#flushCache() empty the cache instead of...

XWIKI-13771: Make XWikiCacheStore#flushCache() empty the cache instead of trying to create a new one
parent 55b246be
No related branches found
No related tags found
No related merge requests found
...@@ -102,32 +102,31 @@ public List<Event> getEvents() ...@@ -102,32 +102,31 @@ public List<Event> getEvents()
} }
public void initCache(XWikiContext context) throws XWikiException 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); CacheManager cacheManager = Utils.getComponent(CacheManager.class);
try { try {
Cache<XWikiDocument> pageCache = int pageCacheCapacity = (int) context.getWiki().ParamAsLong("xwiki.store.cache.capacity", 500);
cacheManager.createNewCache(new LRUCacheConfiguration("xwiki.store.pagecache", capacity)); this.cache =
setCache(pageCache); 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)); .createNewCache(new LRUCacheConfiguration("xwiki.store.pageexistcache", pageExistCacheCapacity));
setPageExistCache(pageExistcache);
} catch (CacheException e) { } catch (CacheException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING,
"Failed to initialize cache", e); "Failed to initialize cache", e);
} }
} }
@Deprecated
@Override
public void initCache(int capacity, int pageExistCacheCapacity, XWikiContext context) throws XWikiException
{
// Do nothing
}
@Override @Override
public XWikiStoreInterface getStore() public XWikiStoreInterface getStore()
{ {
...@@ -170,15 +169,8 @@ public void saveXWikiDoc(XWikiDocument doc, XWikiContext context, boolean bTrans ...@@ -170,15 +169,8 @@ public void saveXWikiDoc(XWikiDocument doc, XWikiContext context, boolean bTrans
@Override @Override
public void flushCache() public void flushCache()
{ {
if (this.cache != null) { getCache().removeAll();
this.cache.dispose(); getPageExistCache().removeAll();
this.cache = null;
}
if (this.pageExistCache != null) {
this.pageExistCache.dispose();
this.pageExistCache = null;
}
} }
@Override @Override
......
...@@ -30,5 +30,10 @@ public interface XWikiCacheStoreInterface extends XWikiStoreInterface ...@@ -30,5 +30,10 @@ public interface XWikiCacheStoreInterface extends XWikiStoreInterface
void flushCache(); 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; void initCache(int capacity, int pageExistCapacity, XWikiContext context) throws XWikiException;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment