List of usage examples for com.google.common.cache CacheBuilder newBuilder
public static CacheBuilder<Object, Object> newBuilder()
From source file:org.apache.usergrid.persistence.collection.uniquevalues.ReservationCache.java
ReservationCache(long ttl) { this.ttl = ttl; cache = CacheBuilder.newBuilder().maximumSize(1000).concurrencyLevel(300) .expireAfterWrite(ttl, TimeUnit.SECONDS).recordStats().build(); }
From source file:org.springmodules.cache.guava.GuavaCache.java
/** * Create a new GuavaCache with the specified name. * @param name the name of the cache */ public GuavaCache(String name) { this(name, CacheBuilder.newBuilder(), true); }
From source file:org.kantega.respiro.security.CachingPasswordChecker.java
public CachingPasswordChecker(PasswordChecker wrapped, int passwordCacheValidity, TimeUnit timeUnit) { this.wrapped = wrapped; this.passwordCacheValidity = passwordCacheValidity; this.cache = CacheBuilder.newBuilder().expireAfterAccess(this.passwordCacheValidity, timeUnit).build(); try {/* www . j av a 2s . c o m*/ secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } byte[] saltBytes = new byte[512]; new SecureRandom().nextBytes(saltBytes); salt = Base64.getEncoder().encodeToString(saltBytes); }
From source file:com.facebook.buck.rules.RuleDepsCache.java
public RuleDepsCache(ListeningExecutorService service, SourcePathRuleFinder ruleFinder) { this.service = service; this.ruleFinder = ruleFinder; this.cache = CacheBuilder.newBuilder().build(); }
From source file:svnserver.ext.gitlab.mapping.GitLabAccess.java
public GitLabAccess(@NotNull LocalContext local, @NotNull GitLabMappingConfig config, int projectId) { this.cache = CacheBuilder.newBuilder().maximumSize(config.getCacheMaximumSize()) .expireAfterWrite(config.getCacheTimeSec(), TimeUnit.SECONDS) .build(new CacheLoader<String, GitlabProject>() { @Override/* w w w . j a v a2 s.c o m*/ public GitlabProject load(@NotNull String userId) throws Exception { final GitlabAPI api = GitLabContext.sure(local.getShared()).connect(); String tailUrl = GitlabProject.URL + "/" + projectId; if (!userId.isEmpty()) { tailUrl += "?sudo=" + userId; } return api.retrieve().to(tailUrl, GitlabProject.class); } }); }
From source file:net.derquinse.bocas.BocasServiceDecorator.java
/** Constructor. */ BocasServiceDecorator(BocasService service, BocasDecorator decorator) { this.service = checkNotNull(service, "The bocas service to decorate must be provided"); this.decorator = checkNotNull(decorator, "The bocas decorator must be provided"); this.buckets = CacheBuilder.newBuilder().build(); }
From source file:org.killbill.commons.skeleton.metrics.TimedResourceMetric.java
public TimedResourceMetric(final Future<MetricRegistry> metricsRegistryFuture, final Class<?> klass, final String name, final int defaultStatusCode) { this.defaultStatusCode = defaultStatusCode; this.metrics = CacheBuilder.newBuilder().build(new CacheLoader<Integer, Timer>() { @Override//from ww w.ja v a 2s . co m public Timer load(final Integer input) { try { return metricsRegistryFuture.get(1, TimeUnit.SECONDS) .timer(MetricRegistry.name(klass, name + "-" + input)); } catch (final InterruptedException ex) { Thread.currentThread().interrupt(); return null; } catch (final TimeoutException ex) { throw new IllegalStateException("Received requests during guice initialization", ex); } catch (final ExecutionException ex) { throw new IllegalStateException(ex); } } }); }
From source file:com.thebuzzmedia.exiftool.core.cache.GuavaVersionCache.java
/** * Create Guava Cache. */ GuavaVersionCache() { this.cache = CacheBuilder.newBuilder().build(); }
From source file:org.vas.http.resource.cache.impl.EtagCacheImpl.java
public EtagCacheImpl(EtagCachePolicy policy) { super();/*from ww w. j ava 2 s . co m*/ this.policy = policy; this.cache = CacheBuilder.newBuilder().softValues().expireAfterWrite(policy.duration, policy.timeUnit) .build(); }
From source file:com.b2international.snowowl.datastore.server.internal.merge.MergeServiceImpl.java
public MergeServiceImpl(Repository repository, int mergeMaxResults) { this.repository = repository; this.merges = CacheBuilder.newBuilder().maximumSize(mergeMaxResults).build(); }