cache

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthCache

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

AuthCache provides caching for password verification results to avoid expensive argon2id re-computation on every request.

func NewAuthCache

func NewAuthCache(cfg AuthCacheConfig) *AuthCache

NewAuthCache creates a new authentication cache.

func (*AuthCache) Clear

func (c *AuthCache) Clear()

Clear removes all entries from the cache.

func (*AuthCache) Enabled

func (c *AuthCache) Enabled() bool

Enabled returns whether the cache is enabled.

func (*AuthCache) Stats

func (c *AuthCache) Stats() (int64, int64, int)

Stats returns cache statistics: hits, misses, and current size.

func (*AuthCache) VerifyKey added in v0.1.0

func (c *AuthCache) VerifyKey(ctx context.Context, keyID, plainKey, storedHash string) (bool, error)

VerifyKey verifies a key hash, using cache if available. keyID is used for logging only. This method is suitable for API keys and web session keys.

func (*AuthCache) VerifyPassword

func (c *AuthCache) VerifyPassword(ctx context.Context, userID, password, storedHash string) (bool, error)

VerifyPassword verifies a password, using cache if available. userID should be a unique identifier for the user (e.g., UID).

type AuthCacheConfig

type AuthCacheConfig struct {
	Enabled    bool
	TTLSeconds int
	MaxSize    int
}

AuthCacheConfig holds configuration for the auth cache.

Jump to

Keyboard shortcuts

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