/** * Creates CacheConfiguration instance with given eviction configuration and id. * * @param evictionConfiguration describes details of entry eviction method. * @param configurationId the configuration identifier. * @since 4.3M1 */ public CacheConfiguration(String configurationId, EntryEvictionConfiguration evictionConfiguration) { setEvictionConfiguration(evictionConfiguration); setConfigurationId(configurationId); }
/** * Sets details of entry eviction method. * * @param evictionConfiguration describes details of entry eviction method. */ private void setEvictionConfiguration(EntryEvictionConfiguration evictionConfiguration) { put(EntryEvictionConfiguration.CONFIGURATIONID, evictionConfiguration); }
/** * @return the eviction configuration as a {@link LRUEvictionConfiguration} instance * @since 7.4M2 */ public LRUEvictionConfiguration getLRUEvictionConfiguration() { return (LRUEvictionConfiguration) get(EntryEvictionConfiguration.CONFIGURATIONID); } }
private Cache<DefaultWikiDescriptor> createCache(String cacheId) throws InitializationException { CacheConfiguration configuration = new CacheConfiguration(cacheId); try { return this.cacheManager.createNewCache(configuration); } catch (CacheException e) { throw new InitializationException( String.format("Failed to initialize wiki descriptor caches [%s]", configuration.getConfigurationId()), e); } }
public XWikiCache newCache(String cacheName) throws XWikiException { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId(cacheName); 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); } }
/** * {@inheritDoc} * * @see com.xpn.xwiki.internal.cache.DocumentCache#create(org.xwiki.cache.config.CacheConfiguration) */ public void create(CacheConfiguration cacheConfiguration) throws CacheException { this.name = cacheConfiguration.getConfigurationId(); this.cache = this.cacheManager.createNewCache(cacheConfiguration); CacheConfiguration mappingCacheConfiguration = (CacheConfiguration) cacheConfiguration.clone(); mappingCacheConfiguration.setConfigurationId(cacheConfiguration.getConfigurationId() + ".mapping"); this.mappingCache = this.cacheManager.createNewCache(cacheConfiguration); this.observationManager.addListener(this.listener); }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException("Failed to initialize the IconSet Cache.", e); } }
/** * @param context the XWiki context used to get cache configuration. * @return the configuration for the LDAP groups cache. */ public static CacheConfiguration getGroupCacheConfiguration(XWikiContext context) { if (cacheConfigurationGroups == null) { XWikiLDAPConfig config = XWikiLDAPConfig.getInstance(); cacheConfigurationGroups = new LRUCacheConfiguration(CACHE_NAME_GROUPS); cacheConfigurationGroups.getLRUEvictionConfiguration().setLifespan(config.getCacheExpiration(context)); } return cacheConfigurationGroups; }
@Override public void initialize() throws InitializationException { try { LRUCacheConfiguration attachmentConfig = new LRUCacheConfiguration(MODULE_NAME + ".attachment", 50); this.attachmentCache = this.cacheManager.createNewCache(attachmentConfig); // We have no idea when to invalidate the cache so lets at least put a time to live LRUCacheConfiguration exteralConfig = new LRUCacheConfiguration(MODULE_NAME + ".external", 50, 3600); this.externalCache = this.cacheManager.createNewCache(exteralConfig); } catch (CacheException e) { throw new InitializationException("Failed to create caches.", e); } }
/** * Creates new LRUCacheConfiguration instance with given configurationId, default max size of 100 and time to live * 0. * * @param configurationId configuration identifier */ public LRUCacheConfiguration(String configurationId) { super(configurationId); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); put(EntryEvictionConfiguration.CONFIGURATIONID, lru); }
/** * @param configuration the XWiki cache API configuration. * @param environment the environment, can be null * @param defaultPropsId the default configuration identifier used to load cache configuration file. */ public AbstractCacheConfigurationLoader(CacheConfiguration configuration, Environment environment, String defaultPropsId) { this.configuration = (CacheConfiguration) configuration.clone(); this.environment = environment; this.defaultPropsId = defaultPropsId; }
/** * Creates CacheConfiguration instance with given eviction configuration and id. * * @param evictionConfiguration describes details of entry eviction method. * @param configurationId the configuration identifier. * @since 4.3M1 */ public CacheConfiguration(String configurationId, EntryEvictionConfiguration evictionConfiguration) { setEvictionConfiguration(evictionConfiguration); setConfigurationId(configurationId); }
/** * Sets details of entry eviction method. * * @param evictionConfiguration describes details of entry eviction method. */ private void setEvictionConfiguration(EntryEvictionConfiguration evictionConfiguration) { put(EntryEvictionConfiguration.CONFIGURATIONID, evictionConfiguration); }
/** * Creates new LRUCacheConfiguration instance with given configurationId, default max size of 100 and time to live * 0. * * @param configurationId configuration identifier */ public LRUCacheConfiguration(String configurationId) { super(configurationId); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); put(EntryEvictionConfiguration.CONFIGURATIONID, lru); }
/** * @param configuration the XWiki cache API configuration. * @param environment the environment, can be null * @param defaultPropsId the default configuration identifier used to load cache configuration file. */ public AbstractCacheConfigurationLoader(CacheConfiguration configuration, Environment environment, String defaultPropsId) { this.configuration = (CacheConfiguration) configuration.clone(); this.environment = environment; this.defaultPropsId = defaultPropsId; }
/** * @return the eviction configuration as a {@link LRUEvictionConfiguration} instance * @since 7.4M2 */ public LRUEvictionConfiguration getLRUEvictionConfiguration() { return (LRUEvictionConfiguration) get(EntryEvictionConfiguration.CONFIGURATIONID); } }
/** * Creates new LRUCacheConfiguration instance with given configurationId and max size, and default time to live 0. * * @param configurationId configuration identifier * @param maxSize maximum cache capacity */ public LRUCacheConfiguration(String configurationId, int maxSize) { super(configurationId); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(maxSize); put(EntryEvictionConfiguration.CONFIGURATIONID, lru); }
/** * Creates new LRUCacheConfiguration instance with given configurationId and max size, and default time to live 0. * * @param configurationId configuration identifier * @param maxSize maximum cache capacity */ public LRUCacheConfiguration(String configurationId, int maxSize) { super(configurationId); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(maxSize); put(EntryEvictionConfiguration.CONFIGURATIONID, lru); }
/** * Creates new LRUCacheConfiguration instance with given configurationId, max size and time to live. * * @param configurationId configuration identifier * @param maxSize maximum cache capacity * @param maxIdle for how long cache entry will be valid (in seconds) since the last time it was used */ public LRUCacheConfiguration(String configurationId, int maxSize, int maxIdle) { super(configurationId); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(maxSize); lru.setMaxIdle(maxIdle); put(EntryEvictionConfiguration.CONFIGURATIONID, lru); }
/** * Creates new LRUCacheConfiguration instance with given configurationId, max size and time to live. * * @param configurationId configuration identifier * @param maxSize maximum cache capacity * @param maxIdle for how long cache entry will be valid (in seconds) since the last time it was used */ public LRUCacheConfiguration(String configurationId, int maxSize, int maxIdle) { super(configurationId); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(maxSize); lru.setMaxIdle(maxIdle); put(EntryEvictionConfiguration.CONFIGURATIONID, lru); }