protected CacheSettings mergeSettings(String name, CacheSettings settings) { if (cacheSettingsDefaultsProvider == null) { return settings; } return cacheSettingsDefaultsProvider.getDefaults(name).override(settings); }
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; } }); }
settings.override(new CacheSettingsBuilder().flushable().build()));