Search in sources :

Example 1 with CacheBuilder

use of org.apache.flink.shaded.guava30.com.google.common.cache.CacheBuilder in project summerb by skarpushin.

the class UserServiceCachedImpl method afterPropertiesSet.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void afterPropertiesSet() throws Exception {
    CacheBuilder cacheBuilder = (CacheBuilder) CacheBuilder.newBuilder().maximumSize(1000).recordStats();
    cacheByEmail = new TransactionBoundCache<String, User>("UserCacheByEmail", cacheBuilder, loaderByEmail);
    cacheByUuid = new TransactionBoundCache<String, User>("UserCacheByUuid", cacheBuilder, loaderByUuid);
    eventBus.register(this);
}
Also used : User(org.summerb.microservices.users.api.dto.User) CacheBuilder(com.google.common.cache.CacheBuilder)

Example 2 with CacheBuilder

use of org.apache.flink.shaded.guava30.com.google.common.cache.CacheBuilder in project streamline by hortonworks.

the class TestApplication method getCacheBackedDao.

private StorageManager getCacheBackedDao(TestConfiguration testConfiguration) {
    StorageProviderConfiguration storageProviderConfiguration = testConfiguration.getStorageProviderConfiguration();
    final StorageManager dao = getStorageManager(storageProviderConfiguration);
    final CacheBuilder cacheBuilder = getGuavaCacheBuilder();
    final Cache<StorableKey, Storable> cache = getCache(dao, cacheBuilder);
    final StorageWriter storageWriter = getStorageWriter(dao);
    return doGetCacheBackedDao(cache, storageWriter);
}
Also used : CacheBuilder(com.google.common.cache.CacheBuilder) StorableKey(com.hortonworks.registries.storage.StorableKey) CacheBackedStorageManager(com.hortonworks.registries.storage.CacheBackedStorageManager) StorageManager(com.hortonworks.registries.storage.StorageManager) Storable(com.hortonworks.registries.storage.Storable) StorageWriter(com.hortonworks.registries.storage.cache.writer.StorageWriter)

Example 3 with CacheBuilder

use of org.apache.flink.shaded.guava30.com.google.common.cache.CacheBuilder in project registry by hortonworks.

the class TestApplication method getCacheBackedDao.

private StorageManager getCacheBackedDao(TestConfiguration testConfiguration) {
    StorageProviderConfiguration storageProviderConfiguration = testConfiguration.getStorageProviderConfiguration();
    final StorageManager dao = getStorageManager(storageProviderConfiguration);
    final CacheBuilder cacheBuilder = getGuavaCacheBuilder();
    final Cache<StorableKey, Storable> cache = getCache(dao, cacheBuilder);
    final StorageWriter storageWriter = getStorageWriter(dao);
    return doGetCacheBackedDao(cache, storageWriter);
}
Also used : CacheBuilder(com.google.common.cache.CacheBuilder) StorableKey(com.hortonworks.registries.storage.StorableKey) CacheBackedStorageManager(com.hortonworks.registries.storage.CacheBackedStorageManager) StorageManager(com.hortonworks.registries.storage.StorageManager) Storable(com.hortonworks.registries.storage.Storable) StorageWriter(com.hortonworks.registries.storage.cache.writer.StorageWriter)

Example 4 with CacheBuilder

use of org.apache.flink.shaded.guava30.com.google.common.cache.CacheBuilder in project registry by hortonworks.

the class GuavaCacheTest method setCache.

private static void setCache() {
    final InMemoryStorageManager dao = new InMemoryStorageManager();
    final CacheBuilder cacheBuilder = getGuavaCacheBuilder();
    cache = getCache(dao, cacheBuilder);
}
Also used : InMemoryStorageManager(com.hortonworks.registries.storage.impl.memory.InMemoryStorageManager) CacheBuilder(com.google.common.cache.CacheBuilder)

Example 5 with CacheBuilder

use of org.apache.flink.shaded.guava30.com.google.common.cache.CacheBuilder in project samza by apache.

the class CachingTableProvider method createDefaultCacheTable.

private ReadWriteUpdateTable createDefaultCacheTable(String tableId, JavaTableConfig tableConfig) {
    long readTtlMs = Long.parseLong(tableConfig.getForTable(tableId, CachingTableDescriptor.READ_TTL_MS, "-1"));
    long writeTtlMs = Long.parseLong(tableConfig.getForTable(tableId, CachingTableDescriptor.WRITE_TTL_MS, "-1"));
    long cacheSize = Long.parseLong(tableConfig.getForTable(tableId, CachingTableDescriptor.CACHE_SIZE, "-1"));
    CacheBuilder cacheBuilder = CacheBuilder.newBuilder();
    if (readTtlMs != -1) {
        cacheBuilder.expireAfterAccess(readTtlMs, TimeUnit.MILLISECONDS);
    }
    if (writeTtlMs != -1) {
        cacheBuilder.expireAfterWrite(writeTtlMs, TimeUnit.MILLISECONDS);
    }
    if (cacheSize != -1) {
        cacheBuilder.maximumSize(cacheSize);
    }
    logger.info(String.format("Creating default cache with: readTtl=%d, writeTtl=%d, maxSize=%d", readTtlMs, writeTtlMs, cacheSize));
    GuavaCacheTable cacheTable = new GuavaCacheTable(tableId + "-def-cache", cacheBuilder.build());
    cacheTable.init(this.context);
    return cacheTable;
}
Also used : CacheBuilder(com.google.common.cache.CacheBuilder) GuavaCacheTable(org.apache.samza.table.caching.guava.GuavaCacheTable)

Aggregations

CacheBuilder (com.google.common.cache.CacheBuilder)12 CacheLoader (com.google.common.cache.CacheLoader)2 CacheBackedStorageManager (com.hortonworks.registries.storage.CacheBackedStorageManager)2 Storable (com.hortonworks.registries.storage.Storable)2 StorableKey (com.hortonworks.registries.storage.StorableKey)2 StorageManager (com.hortonworks.registries.storage.StorageManager)2 StorageWriter (com.hortonworks.registries.storage.cache.writer.StorageWriter)2 InMemoryStorageManager (com.hortonworks.registries.storage.impl.memory.InMemoryStorageManager)1 OnScheduled (org.apache.nifi.annotation.lifecycle.OnScheduled)1 ComponentLog (org.apache.nifi.logging.ComponentLog)1 GuavaCacheTable (org.apache.samza.table.caching.guava.GuavaCacheTable)1 Test (org.junit.Test)1 Bean (org.springframework.context.annotation.Bean)1 User (org.summerb.microservices.users.api.dto.User)1 User (org.summerb.users.api.dto.User)1