cache

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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