Module: Woods::Cache

Defined in:
lib/woods/cache/cache_store.rb,
lib/woods/cache/cache_middleware.rb,
lib/woods/cache/redis_cache_store.rb,
lib/woods/cache/solid_cache_store.rb

Defined Under Namespace

Classes: CacheStore, CachedEmbeddingProvider, CachedRetriever, InMemory, InflightEntry, OwnerAbortedError, RedisCacheStore, SolidCacheStore

Constant Summary collapse

DEFAULT_TTLS =

Default TTLs (in seconds) for each cache domain.

Embedding vectors are stable (same text → same vector) so they get 24h. Metadata and structural context refresh on re-extraction (1h). Search results and formatted context are session-scoped (15min).

{
  embeddings: 86_400,
  metadata: 3_600,
  structural: 3_600,
  search: 900,
  context: 900
}.freeze

Class Method Summary collapse

Class Method Details

.cache_key(domain, *parts) ⇒ String

Build a namespaced cache key from a domain and raw parts.

Parameters:

  • domain (Symbol)

    Cache domain (:embeddings, :metadata, etc.)

  • parts (Array<String>)

    Key components (will be SHA256-hashed if long)

Returns:

  • (String)

    Namespaced key



27
28
29
30
31
# File 'lib/woods/cache/cache_store.rb', line 27

def self.cache_key(domain, *parts)
  raw = parts.join(':')
  suffix = raw.length > 64 ? Digest::SHA256.hexdigest(raw) : raw
  "woods:cache:#{domain}:#{suffix}"
end