protected void invalidateCache() { vCacheRequestFactory.getRequestCache(DESCRIPTORS_REQUEST_CACHE_KEY).removeAll(); vCacheRequestFactory.getRequestCache(REQUEST_CACHE_KEY).removeAll(); vCacheRequestFactory.getRequestCache(REMNANTS_REQUEST_CACHE_KEY).removeAll(); vCacheRequestFactory.getRequestCache(SHALLOW_BEAN_REQUEST_CACHE_KEY).removeAll(); }
protected void invalidateCache(String addonKey) { vCacheRequestFactory.getRequestCache(DESCRIPTORS_REQUEST_CACHE_KEY).remove(addonKey); vCacheRequestFactory.getRequestCache(REQUEST_CACHE_KEY).remove(addonKey); vCacheRequestFactory.getRequestCache(REMNANTS_REQUEST_CACHE_KEY).remove(addonKey); vCacheRequestFactory.getRequestCache(SHALLOW_BEAN_REQUEST_CACHE_KEY).remove(addonKey); }
/** * Returns a new {@link JvmCacheSettings} instance where the current settings * are overridden with settings specified in <tt>overrides</tt>. Only properties * in <tt>overrides</tt> that are present will be applied. * * @param overrides contains the settings to override * @return a new {@link JvmCacheSettings} instance with the <tt>overrides</tt> settings applied. */ public JvmCacheSettings override(JvmCacheSettings overrides) { return new JvmCacheSettings( ifPresent(overrides.getMaxEntries(), getMaxEntries()), ifPresent(overrides.getDefaultTtl(), getDefaultTtl())); }
private StableReadExternalCache<String> getCache(String cacheName) { return cacheFactory.getStableReadExternalCache( cacheName, serializableMarshaller(String.class), new ExternalCacheSettingsBuilder().build() ); }
/** * Returns a new {@link ExternalCacheSettings} instance where the current settings * are overridden with settings specified in <tt>overrides</tt>. * * @param overrides contains the settings to override * @return a new {@link ExternalCacheSettings} instance with the <tt>overrides</tt> settings applied. */ public ExternalCacheSettings override(ExternalCacheSettings overrides) { return new ExternalCacheSettings( ifPresent(overrides.getDefaultTtl(), getDefaultTtl()), ifPresent(overrides.getEntryCountHint(), getEntryCountHint()), ifPresent(overrides.getDataChangeRateHint(), getDataChangeRateHint()), ifPresent(overrides.getEntryGrowthRateHint(), getEntryGrowthRateHint())); }
@Override public ExternalCacheSettings getExternalDefaults(String name) { return new ExternalCacheSettingsBuilder().build(); }
/** * Gets all the properties for a given page id */ @SuppressWarnings("unchecked") public ImmutableMap<String, ImmutableList<ImmutableMap<String, PageProperty>>> get(final long pageId, Supplier<ImmutableMap<String, ImmutableList<ImmutableMap<String, PageProperty>>>> loader) { return join(cacheRef.get().get(Long.toString(pageId), loader)); }
@Override public Optional<ShallowConnectAddon> getShallowAddon(String addonKey) { return vCacheRequestFactory.<String, Optional<ShallowConnectAddon>>getRequestCache(SHALLOW_BEAN_REQUEST_CACHE_KEY).get(addonKey, () -> shallowAddonDBConstructor(addonKey)); }
/** * Constructs an instance initialised with the supplied settings. * * @param settings the settings to configure the instance with. */ public JvmCacheSettingsBuilder(JvmCacheSettings settings) { this.maxEntries = settings.getMaxEntries(); this.defaultTtl = settings.getDefaultTtl(); }
@Override public JvmCacheSettings getJvmDefaults(String name) { return new JvmCacheSettingsBuilder().build(); } }
/** * Returns a new {@link ExternalCacheSettings} instance configured using the supplied settings. * * @return a new {@link ExternalCacheSettings} instance configured using the supplied settings. */ public ExternalCacheSettings build() { return new ExternalCacheSettings( defaultTtl, entryCountHint, dataChangeRateHint, entryGrowthRateHint); }
/** * Returns a new {@link JvmCacheSettings} instance configured using the supplied settings. * * @return a new {@link JvmCacheSettings} instance configured using the supplied settings. */ public JvmCacheSettings build() { return new JvmCacheSettings(maxEntries, defaultTtl); }
static ExternalCacheException mapException(Exception ex) { return new ExternalCacheException(ExternalCacheException.Reason.UNCLASSIFIED_FAILURE, ex); }
@SuppressWarnings("unchecked") private StableReadExternalCache<ImmutableMap<String, ImmutableList<ImmutableMap<String, PageProperty>>>> createCache(VCacheFactory cacheFactory) { return cacheFactory.getStableReadExternalCache( CACHE_NAME, (Marshaller) serializableMarshaller(ImmutableMap.class), new ExternalCacheSettingsBuilder().build() ); }
@Override public Optional<byte[]> getStoredData() { final Lock dataLock = requestLock.get(); // This lock ensures that the supplier for the stored data only gets called once. Ensuring that we only access the db once. dataLock.lock(); try { return vCacheFactory.<String, Optional<byte[]>>getRequestCache(STORED_REQUEST_CACHE_KEY).get(STORED_REQUEST_CACHE_DATA, storedDataRetriever); } finally { dataLock.unlock(); } }