Class ThreadCache
- java.lang.Object
-
- org.apache.kafka.streams.state.internals.ThreadCache
-
public class ThreadCache extends java.lang.ObjectAn in-memory LRU cache store similar toMemoryLRUCachebut byte-based, not record based
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceThreadCache.DirtyEntryFlushListener
-
Constructor Summary
Constructors Constructor Description ThreadCache(org.apache.kafka.common.utils.LogContext logContext, long maxCacheSizeBytes, StreamsMetricsImpl metrics)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDirtyEntryFlushListener(java.lang.String namespace, ThreadCache.DirtyEntryFlushListener listener)Add a listener that is called each time an entry is evicted from the cache or an explicit flush is calledorg.apache.kafka.streams.state.internals.ThreadCache.MemoryLRUCacheBytesIteratorall(java.lang.String namespace)org.apache.kafka.streams.state.internals.LRUCacheEntrydelete(java.lang.String namespace, org.apache.kafka.common.utils.Bytes key)longevicts()voidflush(java.lang.String namespace)longflushes()org.apache.kafka.streams.state.internals.LRUCacheEntryget(java.lang.String namespace, org.apache.kafka.common.utils.Bytes key)longgets()static java.lang.StringnameSpaceFromTaskIdAndStore(java.lang.String taskIDString, java.lang.String underlyingStoreName)The thread cache maintains a set ofNamedCaches whose names are a concatenation of the task ID and the underlying store name.voidput(java.lang.String namespace, org.apache.kafka.common.utils.Bytes key, org.apache.kafka.streams.state.internals.LRUCacheEntry value)voidputAll(java.lang.String namespace, java.util.List<KeyValue<org.apache.kafka.common.utils.Bytes,org.apache.kafka.streams.state.internals.LRUCacheEntry>> entries)org.apache.kafka.streams.state.internals.LRUCacheEntryputIfAbsent(java.lang.String namespace, org.apache.kafka.common.utils.Bytes key, org.apache.kafka.streams.state.internals.LRUCacheEntry value)longputs()org.apache.kafka.streams.state.internals.ThreadCache.MemoryLRUCacheBytesIteratorrange(java.lang.String namespace, org.apache.kafka.common.utils.Bytes from, org.apache.kafka.common.utils.Bytes to)longsize()static java.lang.StringtaskIDfromCacheName(java.lang.String cacheName)Given a cache name of the form taskid-storename, return the task ID.static java.lang.StringunderlyingStoreNamefromCacheName(java.lang.String cacheName)Given a cache name of the form taskid-storename, return the store name.
-
-
-
Constructor Detail
-
ThreadCache
public ThreadCache(org.apache.kafka.common.utils.LogContext logContext, long maxCacheSizeBytes, StreamsMetricsImpl metrics)
-
-
Method Detail
-
puts
public long puts()
-
gets
public long gets()
-
evicts
public long evicts()
-
flushes
public long flushes()
-
nameSpaceFromTaskIdAndStore
public static java.lang.String nameSpaceFromTaskIdAndStore(java.lang.String taskIDString, java.lang.String underlyingStoreName)The thread cache maintains a set ofNamedCaches whose names are a concatenation of the task ID and the underlying store name. This method creates those names.- Parameters:
taskIDString- Task IDunderlyingStoreName- Underlying store name- Returns:
-
taskIDfromCacheName
public static java.lang.String taskIDfromCacheName(java.lang.String cacheName)
Given a cache name of the form taskid-storename, return the task ID.- Parameters:
cacheName-- Returns:
-
underlyingStoreNamefromCacheName
public static java.lang.String underlyingStoreNamefromCacheName(java.lang.String cacheName)
Given a cache name of the form taskid-storename, return the store name.- Parameters:
cacheName-- Returns:
-
addDirtyEntryFlushListener
public void addDirtyEntryFlushListener(java.lang.String namespace, ThreadCache.DirtyEntryFlushListener listener)Add a listener that is called each time an entry is evicted from the cache or an explicit flush is called- Parameters:
namespace-listener-
-
flush
public void flush(java.lang.String namespace)
-
get
public org.apache.kafka.streams.state.internals.LRUCacheEntry get(java.lang.String namespace, org.apache.kafka.common.utils.Bytes key)
-
put
public void put(java.lang.String namespace, org.apache.kafka.common.utils.Bytes key, org.apache.kafka.streams.state.internals.LRUCacheEntry value)
-
putIfAbsent
public org.apache.kafka.streams.state.internals.LRUCacheEntry putIfAbsent(java.lang.String namespace, org.apache.kafka.common.utils.Bytes key, org.apache.kafka.streams.state.internals.LRUCacheEntry value)
-
putAll
public void putAll(java.lang.String namespace, java.util.List<KeyValue<org.apache.kafka.common.utils.Bytes,org.apache.kafka.streams.state.internals.LRUCacheEntry>> entries)
-
delete
public org.apache.kafka.streams.state.internals.LRUCacheEntry delete(java.lang.String namespace, org.apache.kafka.common.utils.Bytes key)
-
range
public org.apache.kafka.streams.state.internals.ThreadCache.MemoryLRUCacheBytesIterator range(java.lang.String namespace, org.apache.kafka.common.utils.Bytes from, org.apache.kafka.common.utils.Bytes to)
-
all
public org.apache.kafka.streams.state.internals.ThreadCache.MemoryLRUCacheBytesIterator all(java.lang.String namespace)
-
size
public long size()
-
-