Documentation
¶
Index ¶
- func BuildKey(p keyParts) string
- func EffectiveTTL(serverCap, clientMaxAge int, tableAllowed bool) int
- func IdentityForCache(req *http.Request, jwtSecret []byte, usePublic bool) string
- func Middleware(store apiconfig.Store, vk *valkey.Client, cfg *serverconf.ServerConfig, ...) http.Handler
- func ParseClientMaxAge(h http.Header) int
- func ParseClientPublic(h http.Header) bool
- func RestKeyPrefix(tenant string) string
- func RestTableFromPath(path string) string
- func ServerCacheOffered(ctx context.Context, cfg *serverconf.ServerConfig, vk *valkey.Client, ...) bool
- func TenantRef(req *http.Request, managedProjectRef string) string
- func VaryHeader(req *http.Request) string
- type Entry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildKey ¶
func BuildKey(p keyParts) string
BuildKey returns a Valkey key tenant:{ref}:rest:{hash}.
func EffectiveTTL ¶
EffectiveTTL returns min(clientMaxAge, serverCap) when table caching is allowed.
func IdentityForCache ¶
IdentityForCache returns the auth component of a cache key. usePublic → shared "global" scope; otherwise role:sub from verified JWT.
func Middleware ¶
func Middleware( store apiconfig.Store, vk *valkey.Client, cfg *serverconf.ServerConfig, schemaFor func(*http.Request) string, maxRowsFor func(*http.Request) string, next http.Handler, ) http.Handler
Middleware caches opt-in GET/HEAD /rest/v1 responses in Valkey.
func ParseClientMaxAge ¶
ParseClientMaxAge reads `X-Supatype-Cache: max-age=N`. Returns 0 when absent or invalid.
func ParseClientPublic ¶
ParseClientPublic reads `public` from X-Supatype-Cache (e.g. max-age=60, public).
func RestKeyPrefix ¶
RestKeyPrefix returns the Valkey SCAN prefix for a tenant's REST cache keys.
func RestTableFromPath ¶
RestTableFromPath returns the first path segment for /table or /table/... (not /rpc).
func ServerCacheOffered ¶
func ServerCacheOffered(ctx context.Context, cfg *serverconf.ServerConfig, vk *valkey.Client, req *http.Request) bool
ServerCacheOffered reports whether Valkey-backed REST caching is enabled for this request. Self-host (dev/standalone) always returns true. Managed Cloud free tier returns false when tenant:{ref}:config has rest_cache_enabled=false.
func VaryHeader ¶
VaryHeader builds a stable Vary value for cacheable REST GET responses.
Types ¶
type Entry ¶
type Entry struct {
StatusCode int `json:"status_code"`
ContentType string `json:"content_type"`
Body []byte `json:"body"`
CachedAt time.Time `json:"cached_at"`
Table string `json:"table,omitempty"`
Scope string `json:"scope,omitempty"`
Method string `json:"method,omitempty"`
Path string `json:"path,omitempty"`
RawQuery string `json:"raw_query,omitempty"`
}
Entry is a cached upstream REST response stored in Valkey.
func DecodeEntryForAdmin ¶
DecodeEntryForAdmin decodes a stored cache payload for admin/CLI introspection.