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()
}
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
......
......@@ -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;
}
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