Example usage for com.google.common.cache CacheBuilder newBuilder

List of usage examples for com.google.common.cache CacheBuilder newBuilder

Introduction

In this page you can find the example usage for com.google.common.cache CacheBuilder newBuilder.

Prototype

public static CacheBuilder<Object, Object> newBuilder() 

Source Link

Document

Constructs a new CacheBuilder instance with default settings, including strong keys, strong values, and no automatic eviction of any kind.

Usage

From source file:io.github.maxymania.powercache.CachingApplier.java

protected Cache<MethodCall, Result> createCache() {
    return CacheBuilder.newBuilder().build();
}

From source file:org.opennms.newts.cassandra.search.GuavaResourceMetadataCache.java

@Inject
public GuavaResourceMetadataCache(@Named("search.resourceMetadata.maxCacheEntries") long maxSize,
        MetricRegistry registry) {//from   w  w  w  .j a v a  2  s.c om
    LOG.info("Initializing resource metadata cache ({} max entries)", maxSize);
    m_cache = CacheBuilder.newBuilder().maximumSize(maxSize).build();

    m_metricReqs = registry.meter(name(getClass(), "metric-reqs"));
    m_metricMisses = registry.meter(name(getClass(), "metric-misses"));
    m_attributeReqs = registry.meter(name(getClass(), "attribute-reqs"));
    m_attributeMisses = registry.meter(name(getClass(), "attribute-misses"));
}

From source file:ec.nbdemetra.ui.tsproviders.DataSourceProviderBuddySupport.java

public DataSourceProviderBuddySupport() {
    fallback = CacheBuilder.newBuilder().build(new CacheLoaderImpl());
}

From source file:com.hortonworks.registries.schemaregistry.client.LoadBalancedFailoverUrlSelector.java

@Override
public void init(Map<String, Object> conf) {
    super.init(conf);
    failedUrls = CacheBuilder.newBuilder()
            .expireAfterWrite((Long) conf.getOrDefault(FAILED_URL_EXPIRY_INTERVAL_MS, 5 * 60 * 1000L),
                    TimeUnit.MILLISECONDS)
            .build();/*from   w ww  .  j av a2 s  .  co  m*/
}

From source file:com.zuoxiaolong.blog.cache.config.GuavaCacheConfig.java

@Bean
@Override/* w w w . j  a v a 2  s  .c  o m*/
public CacheManager cacheManager() {
    SimpleCacheManager cacheManager = new SimpleCacheManager();

    GuavaCache guavaCache = new GuavaCache(BLOG_CACHE,
            CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES) //5
                    .build());

    cacheManager.setCaches(Arrays.asList(guavaCache));
    return cacheManager;
}

From source file:com.google.cloud.dataflow.sdk.runners.inprocess.InProcessSideInputContainer.java

/**
 * Create a new {@link InProcessSideInputContainer} with the provided views and the provided
 * context./*from  w  w w.j av a2  s .c o  m*/
 */
public static InProcessSideInputContainer create(final InProcessEvaluationContext context,
        Collection<PCollectionView<?>> containedViews) {
    LoadingCache<PCollectionViewWindow<?>, AtomicReference<Iterable<? extends WindowedValue<?>>>> viewByWindows = CacheBuilder
            .newBuilder().build(new CallbackSchedulingLoader(context));
    return new InProcessSideInputContainer(containedViews, viewByWindows);
}

From source file:ratpack.session.NewSessionModule.java

@Provides
@Named(LOCAL_MEMORY_SESSION_CACHE)
Cache<String, ByteBuf> localMemorySessionCache() {
    return CacheBuilder.newBuilder().build();
}

From source file:org.petalslink.dsb.registry.RegistryImpl.java

/**
 * // w ww .ja  va 2s .co  m
 */
public RegistryImpl(final RegistryEntryLoader loader, long ttl) {
    this.loader = loader;
    this.ttl = ttl;

    itfs = CacheBuilder.newBuilder().expireAfterAccess(this.ttl, TimeUnit.SECONDS)
            .build(new CacheLoader<String, List<String>>() {

                @Override
                public List<String> load(String key) throws Exception {
                    return RegistryImpl.this.loader.getByInterface(key);
                }
            });

    srvItf = CacheBuilder.newBuilder().expireAfterAccess(this.ttl, TimeUnit.SECONDS)
            .build(new CacheLoader<String, List<String>>() {

                @Override
                public List<String> load(String key) throws Exception {
                    return RegistryImpl.this.loader.getByServiceInterface(key);
                }
            });

    srvEpItf = CacheBuilder.newBuilder().expireAfterAccess(this.ttl, TimeUnit.SECONDS)
            .build(new CacheLoader<String, List<String>>() {

                @Override
                public List<String> load(String key) throws Exception {
                    return RegistryImpl.this.loader.getByServiceInterfaceEndpoint(key);
                }
            });
}

From source file:org.jabylon.rest.ui.model.OSGiAwareBundleStringResourceLoader.java

public OSGiAwareBundleStringResourceLoader() {
    context = FrameworkUtil.getBundle(getClass()).getBundleContext();
    cache = CacheBuilder.newBuilder().build(new CacheLoader<Integer, ClassLoader>() {

        @Override/*ww w  .ja va  2 s .com*/
        public ClassLoader load(Integer key) throws Exception {
            Bundle bundle = context.getBundle(key);
            String bundleName = bundle.getHeaders().get("Bundle-Localisation");
            if (bundleName == null)
                bundleName = "OSGI-INF/l10n/bundle";
            String prefix = "/" + bundleName.substring(0, bundleName.lastIndexOf('/'));
            Enumeration<URL> entries = bundle.findEntries(prefix, "*.properties", false);
            List<URL> urls = Collections.emptyList();
            if (entries != null) {
                urls = new ArrayList<URL>();
                while (entries.hasMoreElements()) {
                    URL url = entries.nextElement();
                    urls.add(url);
                }
            }
            return new BundleClassloader(prefix, urls);
        }

    });
}

From source file:com.codebullets.sagalib.processing.SagaKeyReaderExtractor.java

/**
 * Generates a new instance of SagaKeyReaderExtractor.
 *///from w  w  w. j  a  v a  2s.  c o  m
@Inject
public SagaKeyReaderExtractor(final SagaProviderFactory sagaProviderFactory) {
    this.sagaProviderFactory = sagaProviderFactory;
    knownReaders = CacheBuilder.newBuilder().build();
}