View Source Carve.Cache (Carve v0.6.0)
Request-scoped cache for Carve to prevent redundant data fetching within a single render. Each render operation gets its own isolated cache keyed by a unique ref. TTL defaults to 500ms. Increase if requests involve slow queries. The cache is cleared at end of each render regardless of TTL.
Configuration:
config :carve, Carve.Config,
enable_cache: false,
cache_ttl: 100
Summary
Functions
Clears the cache context from the process dictionary.
Fetches a value from cache or executes the function if not cached. If caching is disabled, always executes the function.
Gets the current cache key from the process dictionary, or creates a new one. Returns nil if caching is disabled.
Creates a new cache context for a render operation. Returns a cache key that should be passed through the render pipeline.
Looks up a cached value without computing it.
Returns {:ok, value} (value may be nil) or :error when the key is
absent or caching is disabled.
Stores a value in the request cache. No-op when caching is disabled.
Functions
Clears the cache context from the process dictionary.
Fetches a value from cache or executes the function if not cached. If caching is disabled, always executes the function.
Gets the current cache key from the process dictionary, or creates a new one. Returns nil if caching is disabled.
Creates a new cache context for a render operation. Returns a cache key that should be passed through the render pipeline.
Looks up a cached value without computing it.
Returns {:ok, value} (value may be nil) or :error when the key is
absent or caching is disabled.
Stores a value in the request cache. No-op when caching is disabled.