KmemoAutoConfiguration

@AutoConfiguration
@EnableConfigurationProperties(value = [KmemoProperties::class])
open class KmemoAutoConfiguration

Auto-configures a SemanticCache bean the moment an Embedder bean is present.

kmemo ships no embedder — you bring one (OpenAI, a local ONNX model, whatever) as a Spring bean, and this wires the cache around it, reading the KmemoProperties under kmemo.*. Everything is conditional and overridable:

  • The store defaults to InMemoryStore. Define your own CacheStore bean — a Redis or pgvector adapter, say — and it is used instead (@ConditionalOnMissingBean).

  • A Verifier bean, if you define one, is attached; multiple CacheListener beans (metrics, logging) are all attached, in @Order.

  • Define your own SemanticCache bean and this backs off entirely.

@Bean fun embedder(client: OpenAiClient) = Embedder { text -> client.embed(text) }
// …and a SemanticCache bean is now available to inject anywhere.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
@Bean
@ConditionalOnMissingBean(value = [CacheStore::class])
open fun kmemoCacheStore(): CacheStore

The default store, used unless the application defines its own CacheStore bean.

Link copied to clipboard
@Bean
@ConditionalOnBean(value = [Embedder::class])
@ConditionalOnMissingBean(value = [SemanticCache::class])
open fun semanticCache(embedder: Embedder, store: CacheStore, properties: KmemoProperties, verifier: ObjectProvider<Verifier>, listeners: ObjectProvider<CacheListener>): SemanticCache

The cache itself: built only when an Embedder is available and no SemanticCache bean exists.