use of org.xwiki.cache.eviction.LRUEvictionConfiguration in project xwiki-platform by xwiki.
the class XWikiCacheServiceStub method newCache.
@Override
public XWikiCache newCache(String cacheName, int capacity) throws XWikiException {
CacheConfiguration configuration = new CacheConfiguration();
configuration.setConfigurationId(cacheName);
LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
lru.setMaxEntries(capacity);
configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
try {
return new XWikiCacheStub(this.cacheFactory.newCache(configuration));
} catch (CacheException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e);
}
}
use of org.xwiki.cache.eviction.LRUEvictionConfiguration in project xwiki-platform by xwiki.
the class FeedPlugin method initCache.
public void initCache(int iCapacity, XWikiContext context) throws XWikiException {
try {
CacheConfiguration configuration = new CacheConfiguration();
configuration.setConfigurationId("xwiki.plugin.feedcache");
LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
lru.setMaxEntries(iCapacity);
lru.setMaxIdle(this.refreshPeriod);
configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
CacheManager cacheManager = Utils.getComponent(CacheManager.class);
this.feedCache = cacheManager.createNewLocalCache(configuration);
} catch (CacheException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create cache");
}
}
use of org.xwiki.cache.eviction.LRUEvictionConfiguration in project xwiki-platform by xwiki.
the class DefaultSecurityCache method newCache.
/**
* @return a new configured security cache
* @throws InitializationException if a CacheException arise during creation
*/
private Cache<SecurityCacheEntry> newCache() throws InitializationException {
CacheConfiguration cacheConfig = new CacheConfiguration();
cacheConfig.setConfigurationId("platform.security.authorization.cache");
LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
lru.setMaxEntries(DEFAULT_CAPACITY);
cacheConfig.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
try {
return cacheManager.createNewCache(cacheConfig);
} catch (Exception e) {
throw new InitializationException(String.format("Unable to create the security cache with a capacity of [%d] entries", lru.getMaxEntries()), e);
}
}
use of org.xwiki.cache.eviction.LRUEvictionConfiguration in project xwiki-platform by xwiki.
the class XWikiCacheServiceStub method newLocalCache.
@Override
public XWikiCache newLocalCache(int capacity) throws XWikiException {
CacheConfiguration configuration = new CacheConfiguration();
LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
lru.setMaxEntries(capacity);
configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
try {
return new XWikiCacheStub(this.localCacheFactory.newCache(configuration));
} catch (CacheException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e);
}
}
use of org.xwiki.cache.eviction.LRUEvictionConfiguration in project xwiki-platform by xwiki.
the class DefaultDocumentCacheTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
this.cache = (DefaultDocumentCache<String>) getComponentManager().getInstance(DocumentCache.class);
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setConfigurationId("documentcachetest");
LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
cacheConfiguration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
this.cache.create(cacheConfiguration);
this.document = new XWikiDocument(new DocumentReference("wiki", "space", "page"));
this.document.setOriginalDocument(this.document.clone());
this.mockXWiki = getMockery().mock(XWiki.class);
getContext().setWiki(this.mockXWiki);
getMockery().checking(new Expectations() {
{
allowing(mockXWiki).getDocument(document.getDocumentReference(), getContext());
will(returnValue(document));
}
});
}
Aggregations