public CachingLabelStore(final OfBizLabelStore delegateStore, CacheManager cacheManager) { this.delegateStore = delegateStore; cache = cacheManager.getCache(CachingLabelStore.class.getName() + ".cache", new LabelCacheLoader(), new CacheSettingsBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maxEntries(1000).build()); }
public CachingPluginIndexConfigurationManager(final OfBizPluginIndexConfigurationManager delegate, final CacheManager cacheManager) { this.delegate = delegate; this.byEntityKeyCache = cacheManager.getCache(CachingPluginIndexConfigurationManager.class.getName() + ".cacheByEntityKey", new ByEntityKeyCacheLoader(), new CacheSettingsBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maxEntries(1000).build()); }
protected <V> CachedReference<V> createDistributedCachedReference(String name, Supplier<V> supplier, CacheSettings settings) { // override the settings to ensure the reference is flushable and the max is set to 1000. A low value for // maxEntries would trigger continuous cache invalidations because of the way map eviction works in Hazelcast. final CacheSettings overriddenSettings = checkNotNull(settings, "settings").override( new CacheSettingsBuilder().flushable().maxEntries(1000).build()); final String mapName = PREFIX_CACHE_REFERENCE + name; configureMap(mapName, overriddenSettings); final IMap<String, OsgiSafe<V>> map = hazelcast.getMap(mapName); return new HazelcastCachedReference<V>(name, map, supplier, this); }
@Nonnull @SuppressWarnings("unchecked") @Override public <V> CachedReference<V> getCachedReference(@Nonnull final String name, @Nonnull final com.atlassian.cache.Supplier<V> supplier, @Nonnull final CacheSettings settings) { // Force the cache settings to be flushable and a maximum size of one. final CacheSettings overridenSettings = settings.override( new CacheSettingsBuilder().flushable().maxEntries(1).build()); return cacheCreationLocks.get(name).withLock(new com.atlassian.util.concurrent.Supplier<DelegatingCachedReference<V>>() { @Override public DelegatingCachedReference<V> get() { final Ehcache spCache = getLoadingCache(name, overridenSettings, new ValueProcessorAtlassianCacheLoaderDecorator(new SupplierAdapter<>(supplier), valueProcessor)); final DelegatingCachedReference<V> cache = DelegatingCachedReference.create(spCache, overridenSettings, valueProcessor); caches.put(name, new WeakSupplier<ManagedCache>(cache)); return cache; } }); }
protected Cache<String, Long> makeSizeLimitedCache(int maxEntries) { CacheSettings required = settingsBuilder().maxEntries(maxEntries).build(); final Cache<String, Long> cache = factory.getCache("mycache", null, required); assertEmpty(cache); return cache; }
public CachingFavouritesStore(final FavouritesStore delegateStore, final CacheManager cacheManager) { this.delegateStore = notNull("delegateStore", delegateStore); favouritesCache = cacheManager.getCache(CachingFavouritesStore.class.getName() + ".favouritesCache", new KeyCollectionCacheLoader(), new CacheSettingsBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maxEntries(1000).build()); }
@Autowired public DefaultRemoteCapabilitiesService(ApplicationLinkService applicationLinkService, ApplinkHelper applinkHelper, ApplinksRequestCache applinksRequestCache, EventPublisher eventPublisher, AppLinksManifestDownloader manifestDownloader, PermissionValidationService permissionValidationService, ServiceExceptionFactory serviceExceptionFactory, CacheFactory cacheFactory) { this.applicationLinkService = applicationLinkService; this.applinkHelper = applinkHelper; this.applinksRequestCache = applinksRequestCache; this.eventPublisher = eventPublisher; this.manifestDownloader = manifestDownloader; this.permissionValidationService = permissionValidationService; this.serviceExceptionFactory = serviceExceptionFactory; this.capabilitiesCache = cacheFactory.getCache("applinks.capabilities", null, new CacheSettingsBuilder() .local() .maxEntries(MAX_CACHE_SIZE) .build()); }
public IssueSecuritySchemeManagerImpl(ProjectManager projectManager, SecurityTypeManager securityTypeManager, PermissionContextFactory permissionContextFactory, SchemeFactory schemeFactory, EventPublisher eventPublisher, final OfBizDelegator ofBizDelegator, final GroupManager groupManager, NodeAssociationStore nodeAssociationStore, CacheManager cacheManager, final ApplicationProperties applicationProperties) { super(projectManager, securityTypeManager, permissionContextFactory, schemeFactory, nodeAssociationStore, ofBizDelegator, groupManager, eventPublisher, cacheManager); this.projectManager = projectManager; this.nodeAssociationStore = nodeAssociationStore; this.ofBizDelegator = ofBizDelegator; this.schemeIdToSecuritiesCache = cacheManager.getCache(IssueSecuritySchemeManagerImpl.class.getName() + ".schemeIdToSecuritiesCache", new SecuritiesByFieldCacheLoader("scheme"), new CacheSettingsBuilder().maxEntries(64).build()); final int maxEntries = PropertiesUtil.getIntProperty(applicationProperties, APKeys.JIRA_SECURITY_LEVEL_PERMISSIONS_CACHE_MAX_SIZE, DEFAULT_JIRA_SECURITY_LEVEL_PERMISSIONS_CACHE_MAX_SIZE); this.securityLevelToPermissionsCache = cacheManager.getCache(IssueSecuritySchemeManagerImpl.class.getName() + "securityLevelToPermissionsCache", new PermissionBySecurityLevelCacheLoader(), new CacheSettingsBuilder().expireAfterAccess(30, TimeUnit.MINUTES).maxEntries(maxEntries).build()); }
protected Cache<String, Long> makeSizeLimitedCache(final int maxEntries, final AtomicInteger loadCounter) { // Build a Cache using the builder CacheLoader<String, Long> loader = new CacheLoader<String, Long>() { @Nonnull @Override public Long load(@Nonnull final String key) { loadCounter.incrementAndGet(); return Long.valueOf(key); } }; CacheSettings settings = settingsBuilder().maxEntries(maxEntries).build(); final Cache<String, Long> cache = factory.getCache("mycache", loader, settings); assertEmpty(cache); return cache; }
@Override public boolean updateMaxEntries(int newValue) { CacheSettings newCacheSettings = new CacheSettingsBuilder(getCacheSettings()).maxEntries(newValue).build(); return cacheManager.updateCacheSettings(getHazelcastMapName(), newCacheSettings); }
@Override public boolean updateMaxEntries(int newValue) { if (!super.updateMaxEntries(newValue)) { return false; } CacheSettings settings = new CacheSettingsBuilder(getCacheSettings()) .maxEntries(HazelcastMapConfigConfigurator.HYBRID_MULTIPLIER * newValue) .build(); cacheManager.updateCacheSettings(getHazelcastMapName(), settings); return true; }
DefaultApplicationRoleManager.class.getName() + ".applicationRoleGroups", new RoleLoader(), new CacheSettingsBuilder().expireAfterAccess(30, TimeUnit.MINUTES).maxEntries(100).build());