cache

package
v0.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package cache holds the cache-aside decorators of storage ports. Valkey keeps what is read on every request and changes rarely; a decorator never answers differently from the port it wraps, only sooner.

Index

Constants

View Source
const TokenTTL = 30 * time.Second

TokenTTL bounds a cached row's life should a post-commit bump fail.

Variables

This section is empty.

Functions

This section is empty.

Types

type None

type None struct{}

None is the absent cache: every store answers directly.

func (None) Authn

func (None) Authn(inner authn.Store) authn.Store

Authn answers the store itself.

func (None) Invalidate added in v0.0.18

func (None) Invalidate(context.Context, uuid.UUID) error

Invalidate has nothing to drop.

func (None) Manage

func (None) Manage(inner tokens.Store) tokens.Store

Manage answers the store itself.

func (None) Users

func (None) Users(inner users.Store) users.Store

Users answers the store itself.

type Tokens

type Tokens struct {
	// contains filtered or unexported fields
}

Tokens caches token lookups by digest. The cache key carries the account's token generation; every token mutation bumps it, so a revoked or regenerated token is never answered from the cache. Bearers are not cached: authentication always reads them live.

func NewTokens

func NewTokens(client valkey.AsideClient, ttl time.Duration) Tokens

NewTokens builds the token cache over a cache-aside client.

func (Tokens) Authn

func (t Tokens) Authn(inner authn.Store) authn.Store

Authn decorates the authentication store's token lookup.

func (Tokens) Invalidate added in v0.0.18

func (t Tokens) Invalidate(ctx context.Context, accountID uuid.UUID) error

Invalidate starts a new token generation: a token written outside the decorated ports (the declared catalog) is never answered from the cache.

func (Tokens) Manage

func (t Tokens) Manage(inner tokens.Store) tokens.Store

Manage decorates the token management store: regenerating or revoking a token starts a new generation.

func (Tokens) Users

func (t Tokens) Users(inner users.Store) users.Store

Users decorates the users store: revoking a user's tokens (password changes and resets) starts a new generation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL