import org.apache.kafka.streams.state.Stores
// Using Scala API for Kafka Streams
import org.apache.kafka.streams.scala.Serdes
val storeBuilder = Stores.keyValueStoreBuilder(
Stores.inMemoryKeyValueStore("store-name"),
Serdes.Integer,
Serdes.Long)
scala> :type storeBuilder
org.apache.kafka.streams.state.StoreBuilder[org.apache.kafka.streams.state.KeyValueStore[Int,Long]]
import org.apache.kafka.streams.state.internals.KeyValueStoreBuilder
assert(storeBuilder.isInstanceOf[KeyValueStoreBuilder[_, _]])
KeyValueStoreBuilder
KeyValueStoreBuilder
is a StoreBuilder (indirectly as a AbstractStoreBuilder) that allows for building KeyValueStores.
KeyValueStoreBuilder
can be created using Stores.keyValueStoreBuilder.
When requested for a state store, KeyValueStoreBuilder
creates a new MeteredKeyValueBytesStore (with the state store from the KeyValueBytesStoreSupplier).
With caching enabled, build
creates a CachingKeyValueStore.
With logging enabled, build
creates a ChangeLoggingKeyValueBytesStore.
Note
|
Logging is enabled by default. |
Building KeyValueStore — build
Method
KeyValueStore<K, V> build()
Note
|
build is part of the StoreBuilder Contract to build a state store.
|
build
first requests the KeyValueBytesStoreSupplier for a StateStore.
build
then creates a MeteredKeyValueStore (possibly with a CachingKeyValueStore with caching enabled and ChangeLoggingKeyValueBytesStore with logging enabled).
maybeWrapLogging
Internal Method
KeyValueStore<Bytes, byte[]> maybeWrapLogging(
KeyValueStore<Bytes, byte[]> inner)
maybeWrapLogging
simply returns the given inner KeyValueStore with logging disabled.
Otherwise, with logging enabled, maybeWrapLogging
creates a ChangeLoggingKeyValueBytesStore.
Note
|
maybeWrapLogging is used exclusively when KeyValueStoreBuilder is requested to build a KeyValueStore.
|
maybeWrapCaching
Internal Method
KeyValueStore<Bytes, byte[]> maybeWrapCaching(
KeyValueStore<Bytes, byte[]> inner)
maybeWrapCaching
simply returns the given inner KeyValueStore with caching disabled.
Otherwise, with caching enabled, maybeWrapCaching
creates a CachingKeyValueStore.
Note
|
maybeWrapCaching is used exclusively when KeyValueStoreBuilder is requested to build a KeyValueStore.
|