List of usage examples for com.google.common.cache CacheBuilder newBuilder
public static CacheBuilder<Object, Object> newBuilder()
From source file:io.gromit.geolite2.cache.GuavaCache.java
/** * Instantiates a new guava cache. */ public GuavaCache() { cache = CacheBuilder.newBuilder().maximumSize(DEFAULT_CAPACITY).build(); }
From source file:com.netflix.exhibitor.core.controlpanel.ControlPanelValues.java
public ControlPanelValues(final Preferences preferences) { this.preferences = preferences; cache = CacheBuilder.newBuilder().build(new CacheLoader<ControlPanelTypes, Boolean>() { @Override//from w w w . j a v a 2s. c o m public Boolean load(ControlPanelTypes type) throws Exception { return preferences.getBoolean(makeKey(type), true); } }); }
From source file:rub.nds.oidc.oidc_op.OIDCCache.java
/** * *///from w w w .j ava 2 s .co m public static void initialize() { OIDCCache.cachedIDs = CacheBuilder.newBuilder().maximumSize(1000) .expireAfterWrite(OIDCCache.cacheDuration, TimeUnit.MINUTES) .removalListener(new RemovalListener<String, TokenCollection>() { @Override public void onRemoval(RemovalNotification<String, TokenCollection> rn) { _log.debug("ID " + rn.getKey() + " has been removed from the cache."); } }).build(new CacheLoader<String, TokenCollection>() { @Override public TokenCollection load(String key) throws ExecutionException { return getElement(key); } }); }
From source file:com.jdon.components.guavacache.GuavaCacheProvider.java
@Override public void start() { cache = CacheBuilder.newBuilder().maximumSize(guavaCacheConf.getMaximumSize()).build(); }
From source file:com.palantir.atlasdb.impl.TableMetadataCache.java
public TableMetadataCache(final KeyValueService kvs) { this.cache = CacheBuilder.newBuilder().expireAfterAccess(15, TimeUnit.MINUTES) .build(new CacheLoader<String, TableMetadata>() { @Override/*from w w w . j a v a 2 s . c om*/ public TableMetadata load(String tableName) throws Exception { byte[] rawMetadata = kvs.getMetadataForTable(tableName); if (rawMetadata == null || rawMetadata.length == 0) { return EMPTY; } return TableMetadata.BYTES_HYDRATOR.hydrateFromBytes(rawMetadata); } }); }
From source file:com.thinkbiganalytics.metadata.jpa.cache.CacheBean.java
public CacheBean() { cache = CacheBuilder.newBuilder().build(); }
From source file:se252.jan15.calvinandhobbes.project0.IIScCampusMapSDB_GETService.java
public static void cacheInit() { categoryCache = CacheBuilder.newBuilder().maximumSize(7) // maximum 7 records can be cached .expireAfterAccess(10, TimeUnit.MINUTES) // cache will expire after 10 minutes of access .build(new CacheLoader<String, LayerInfo[]>() { // build the cacheloader @Override// w ww.ja v a2 s . c o m public LayerInfo[] load(String category) throws Exception { return getCategoryData(category); } }); }
From source file:org.apache.aurora.scheduler.stats.CachedCounters.java
@VisibleForTesting @Inject/*from w ww . j av a 2 s. c om*/ public CachedCounters(final StatsProvider stats) { cache = CacheBuilder.newBuilder().build(new CacheLoader<String, AtomicLong>() { @Override public AtomicLong load(String key) { return stats.makeCounter(key); } }); }
From source file:se252.jan15.calvinandhobbes.project0.IIScCampusMapRDBMS_GETService.java
public static void cacheInit() { categoryCache = CacheBuilder.newBuilder().maximumSize(7) // maximum 7 records can be cached .expireAfterAccess(10, TimeUnit.MINUTES) // cache will expire after 10 minutes of access .build(new CacheLoader<String, Object[]>() { // build the cacheloader @Override/*from w ww.ja v a2 s. com*/ public Object[] load(String category) throws Exception { return getCategoryData(category); } }); }
From source file:org.wso2.carbon.appfactory.git.ApplicationCache.java
public ApplicationCache(GitBlitConfiguration configuration) { int cacheExpiryTime = Integer .parseInt(configuration.getProperty(GitBlitConstants.APPFACTORY_CACHE_EXPIRY_TIME, "1")); cache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(cacheExpiryTime, TimeUnit.MINUTES) .build();/* w w w . ja v a 2 s . c o m*/ }