public void invalidateRowCache() { rowCache.clear(); }
/** * @return true if @param key is contained in the row cache */ public boolean containsCachedParition(DecoratedKey key) { return CacheService.instance.rowCache.getCapacity() != 0 && CacheService.instance.rowCache.containsKey(new RowCacheKey(metadata.ksAndCFName, key)); }
public ClockAndCount getCachedCounter(ByteBuffer partitionKey, Clustering clustering, ColumnDefinition column, CellPath path) { if (CacheService.instance.counterCache.getCapacity() == 0L) // counter cache disabled. return null; return CacheService.instance.counterCache.get(CounterCacheKey.create(metadata.ksAndCFName, partitionKey, clustering, column, path)); }
public void putCachedCounter(ByteBuffer partitionKey, Clustering clustering, ColumnDefinition column, CellPath path, ClockAndCount clockAndCount) { if (CacheService.instance.counterCache.getCapacity() == 0L) // counter cache disabled. return; CacheService.instance.counterCache.put(CounterCacheKey.create(metadata.ksAndCFName, partitionKey, clustering, column, path), clockAndCount); }
private AutoSavingCache<CounterCacheKey, ClockAndCount> initCounterCache() { logger.info("Initializing counter cache with capacity of {} MBs", DatabaseDescriptor.getCounterCacheSizeInMB()); long capacity = DatabaseDescriptor.getCounterCacheSizeInMB() * 1024 * 1024; AutoSavingCache<CounterCacheKey, ClockAndCount> cache = new AutoSavingCache<>(ConcurrentLinkedHashCache.<CounterCacheKey, ClockAndCount>create(capacity), CacheType.COUNTER_CACHE, new CounterCacheSerializer()); int keysToSave = DatabaseDescriptor.getCounterCacheKeysToSave(); logger.info("Scheduling counter cache save to every {} seconds (going to save {} keys).", DatabaseDescriptor.getCounterCacheSavePeriod(), keysToSave == Integer.MAX_VALUE ? "all" : keysToSave); cache.scheduleSaving(DatabaseDescriptor.getCounterCacheSavePeriod(), keysToSave); return cache; }
IRowCacheEntry cached = CacheService.instance.rowCache.get(key); if (cached != null) boolean sentinelSuccess = CacheService.instance.rowCache.putIfAbsent(key, sentinel); boolean sentinelReplaced = false; CacheService.instance.rowCache.replace(key, sentinel, toCache);
File dataPath = getCacheDataPath(CURRENT_VERSION); File crcPath = getCacheCrcPath(CURRENT_VERSION); if (dataPath.exists() && crcPath.exists()) Pair<K, V> entry = future.get(); if (entry != null && entry.right != null) put(entry.left, entry.right); put(entry.left, entry.right);
public boolean isCounterCacheEnabled() { return metadata.isCounter() && CacheService.instance.counterCache.getCapacity() > 0; }
logger.info(String.format("%-25s%10s%25s%25s", "KeyCache", keyCache.weightedSize(), keyCache.getCapacity(), keyCacheKeysToSave == Integer.MAX_VALUE ? "all" : keyCacheKeysToSave)); rowCache.weightedSize(), rowCache.getCapacity(), rowCacheKeysToSave == Integer.MAX_VALUE ? "all" : rowCacheKeysToSave));
private ListenableFuture<?> loadRowAndKeyCacheAsync() { final ListenableFuture<Integer> keyCacheLoad = CacheService.instance.keyCache.loadSavedAsync(); final ListenableFuture<Integer> rowCacheLoad = CacheService.instance.rowCache.loadSavedAsync(); @SuppressWarnings("unchecked") ListenableFuture<List<Integer>> retval = Futures.successfulAsList(keyCacheLoad, rowCacheLoad); return retval; }
/** * @return the cached partition for @param key if it is already present in the cache. * Not that this will not readAndCache the parition if it is not present, nor * are these calls counted in cache statistics. * * Note that this WILL cause deserialization of a SerializingCache partition, so if all you * need to know is whether a partition is present or not, use containsCachedParition instead. */ public CachedPartition getRawCachedPartition(DecoratedKey key) { if (!isRowCacheEnabled()) return null; IRowCacheEntry cached = CacheService.instance.rowCache.getInternal(new RowCacheKey(metadata.ksAndCFName, key)); return cached == null || cached instanceof RowCacheSentinel ? null : (CachedPartition)cached; }
@Override public Integer call() { return loadSaved(); } });
public Future<?> submitWrite(int keysToSave) { return CompactionManager.instance.submitCacheWrite(getWriter(keysToSave)); }
File path = getCachePath(CURRENT_VERSION); if (path.exists()) Pair<K, V> entry = future.get(); if (entry != null && entry.right != null) put(entry.left, entry.right); put(entry.left, entry.right);
private AutoSavingCache<CounterCacheKey, ClockAndCount> initCounterCache() { logger.info("Initializing counter cache with capacity of {} MBs", DatabaseDescriptor.getCounterCacheSizeInMB()); long capacity = DatabaseDescriptor.getCounterCacheSizeInMB() * 1024 * 1024; AutoSavingCache<CounterCacheKey, ClockAndCount> cache = new AutoSavingCache<>(ConcurrentLinkedHashCache.<CounterCacheKey, ClockAndCount>create(capacity), CacheType.COUNTER_CACHE, new CounterCacheSerializer()); int keysToSave = DatabaseDescriptor.getCounterCacheKeysToSave(); logger.info("Scheduling counter cache save to every {} seconds (going to save {} keys).", DatabaseDescriptor.getCounterCacheSavePeriod(), keysToSave == Integer.MAX_VALUE ? "all" : keysToSave); cache.scheduleSaving(DatabaseDescriptor.getCounterCacheSavePeriod(), keysToSave); return cache; }
IRowCacheEntry cached = CacheService.instance.rowCache.get(key); if (cached != null) boolean sentinelSuccess = CacheService.instance.rowCache.putIfAbsent(key, sentinel); boolean sentinelReplaced = false; CacheService.instance.rowCache.replace(key, sentinel, toCache);
File dataPath = getCacheDataPath(CURRENT_VERSION); File crcPath = getCacheCrcPath(CURRENT_VERSION); if (dataPath.exists() && crcPath.exists()) Pair<K, V> entry = future.get(); if (entry != null && entry.right != null) put(entry.left, entry.right); put(entry.left, entry.right);
public boolean isKeyCacheEnabled() { return metadata.params.caching.cacheKeys() && CacheService.instance.keyCache.getCapacity() > 0; }
public void putCachedCounter(ByteBuffer partitionKey, Clustering clustering, ColumnDefinition column, CellPath path, ClockAndCount clockAndCount) { if (CacheService.instance.counterCache.getCapacity() == 0L) // counter cache disabled. return; CacheService.instance.counterCache.put(CounterCacheKey.create(metadata.ksAndCFName, partitionKey, clustering, column, path), clockAndCount); }
logger.info(String.format("%-25s%10s%25s%25s", "KeyCache", keyCache.weightedSize(), keyCache.getCapacity(), keyCacheKeysToSave == Integer.MAX_VALUE ? "all" : keyCacheKeysToSave)); rowCache.weightedSize(), rowCache.getCapacity(), rowCacheKeysToSave == Integer.MAX_VALUE ? "all" : rowCacheKeysToSave));