Add CacheConfig: typed cache-tag/lifetime functor over Cache#27
Merged
Conversation
A functor that wraps the Cache 'use cache' tag + lifetime bindings with typed variants, so each app supplies its own cache-tag type while sharing one implementation. The tag's string coercion lives at the call site (the app's tagToString) since an abstract functor type can't be coerced to string; Defaults carries the common lifetime enum (Seconds … Max).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
CacheConfig(GreenfinityNext.CacheConfig) — a functor wrapping theCache'use cache'tag + lifetime bindings with typed variants, so each app supplies its own cache-tag type while sharing one implementation. (Lifts the per-app helper that lived in njc-2026'sContent_Cache.)API
Why
tagToStringin the config (not a coercion inside the functor)(tag :> string)is compile-checked and only works on a concrete@as-string variant; an abstract functor type (Config.tag) "is not a subtype of string", so the coercion has to happen where the concrete type is known — the app'stagToString. There's no built-in "coercible-to-string" constraint and no type classes, so passing the conversion is the idiomatic stand-in.DefaultsLifecarries the common lifetime enum so appsincludeit.Usage
The config must be a named module (the functor result mentions
Config.tag/Config.life, so an inline struct gives "parameter cannot be eliminated"):