Cache settings shared by source adapters.
The built-in adapters accept these options, and a custom adapter can append
schema/0 to its own option schema to accept them too:
@schema NimbleOptions.new!([bucket: [type: :string, required: true]] ++ CacheSettings.schema())After validating, validate/1 rejects a lifetime or stale window on an
immutable source. fields/2 then turns the validated options into the
cache fields of ImagePipe.Source.Resolved. Their effect is explained in
Caching and freshness.
Options
:stable(:autoor:immutable) -:immutablemarks an immutable source: an identifier always names the same bytes, so its originals and processed images never expire and are never revalidated. With:auto, each original is identified by its content. See immutable sources. The default value is:auto.:cache_policy(keyword/0) - Cache policy for this source, with the fields ofImagePipe.Source.CachePolicy. Each field it sets replaces that field of the:source_cache_policyofImagePipe.config/1. A source withstable: :immutablecan't set a:freshnessduration or a:stale_while_revalidatewindow. The default value is[].:internal_cache(:auto,:enabled, or:disabled) -:disabledkeeps this source's originals and processed images out of the caches, including images that use this source for a watermark.:autoand:enabledcache what the source's storage policy allows. The default value is:auto.:http_cache(:inherit,:validators,:auto,:public, or:private) - HTTP cache headers for responses from this source.:inherituses the mount's:http_cache(seeImagePipe.Plug), and any other value replaces it. See per-source modes. The default value is:inherit.
Summary
Functions
Returns the :internal_cache, :http_cache, and :cache_semantics fields
of ImagePipe.Source.Resolved.
Whether the options mark the source as immutable.
NimbleOptions schema entries for the shared cache settings.
Rejects a TTL or stale-while-revalidate window on an immutable source, which has no freshness deadline. Returns the options unchanged when valid.
Functions
Returns the :internal_cache, :http_cache, and :cache_semantics fields
of ImagePipe.Source.Resolved.
Takes the validated options and:
:stable?- whether this source's bytes can't change, either because the options trust it or because the source itself pins them.:seed- the byte-identity seed used when the source is stable. It must not contain secrets.:copy?- whether to keep a local copy of the original in the input pool. Remote adapters passtrue.
A source that isn't stable is identified by its content. internal_cache: :auto enables internal caching.
Whether the options mark the source as immutable.
@spec schema() :: keyword()
NimbleOptions schema entries for the shared cache settings.
Rejects a TTL or stale-while-revalidate window on an immutable source, which has no freshness deadline. Returns the options unchanged when valid.