@Override
    public StateStore build() {
        final KeyValueBytesStoreSupplier supplier = materialized.storeSupplier() == null
                ? dslStoreSuppliers().keyValueStore(new DslKeyValueParams(materialized.storeName(), true))
                : (KeyValueBytesStoreSupplier) materialized.storeSupplier();

        final StoreBuilder<?> builder;
        if (supplier instanceof VersionedBytesStoreSupplier) {
            builder = Stores.versionedKeyValueStoreBuilder(
                    (VersionedBytesStoreSupplier) supplier,
                    materialized.keySerde(),
                    materialized.valueSerde());
        } else {
            builder = Stores.timestampedKeyValueStoreBuilder(
                    supplier,
                    materialized.keySerde(),
                    materialized.valueSerde());
        }

        if (materialized.loggingEnabled()) {
            builder.withLoggingEnabled(materialized.logConfig());
        } else {
            builder.withLoggingDisabled();
        }

        if (materialized.cachingEnabled()) {
            if (!(builder instanceof VersionedKeyValueStoreBuilder)) {
                builder.withCachingEnabled();
            } else {
                LOG.info("Not enabling caching for store '{}' as versioned stores do not support caching.", supplier.name());
            }
        }


        return builder.build();
    }
Materializes a key-value store as either a {@link TimestampedKeyValueStoreBuilder} or a
{@link VersionedKeyValueStoreBuilder} depending on whether the store is versioned or not.
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KeyValueStoreMaterializer.java