cache

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultIDPCacheExpirationMax   = 7 * 24 * time.Hour // 7 days
	DefaultIDPCacheExpirationMin   = 3 * 24 * time.Hour // 3 days
	DefaultIDPCacheCleanupInterval = 30 * time.Minute
	DefaultIDPCacheOpenConn        = 100
)
View Source
const (
	// DefaultStoreMaxTimeout is the default max timeout for the shared cache store.
	DefaultStoreMaxTimeout = 7 * 24 * time.Hour
	// DefaultStoreCleanupInterval is the default cleanup interval for the shared cache store.
	DefaultStoreCleanupInterval = 30 * time.Minute
	// DefaultStoreMaxConn is the default max connections for the shared cache store.
	DefaultStoreMaxConn = 1000
)
View Source
const RedisStoreEnvVar = "NB_CACHE_REDIS_ADDRESS"

RedisStoreEnvVar is the environment variable that determines if a redis store should be used. The value should follow redis URL format. https://github.com/redis/redis-specifications/blob/master/uri/redis.txt

Variables

This section is empty.

Functions

func GetAddrFromEnv added in v0.69.0

func GetAddrFromEnv() string

GetAddrFromEnv returns the redis address from the environment variable RedisStoreEnvVar or its legacy counterpart.

func NewStore

func NewStore(ctx context.Context, maxTimeout, cleanupInterval time.Duration, maxConn int) (store.StoreInterface, error)

NewStore creates a new cache store with the given max timeout and cleanup interval. It checks for the environment Variable RedisStoreEnvVar to determine if a redis store should be used. If the environment variable is set, it will attempt to connect to the redis store.

Types

type AccountUserDataCache

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

AccountUserDataCache wraps the basic Get, Set and Delete methods for []*idp.UserData objects.

func NewAccountUserDataCache

func NewAccountUserDataCache(loadableFunc cache.LoadFunction[any], store store.StoreInterface) *AccountUserDataCache

NewAccountUserDataCache creates a new AccountUserDataCache object.

func (*AccountUserDataCache) Delete

func (a *AccountUserDataCache) Delete(ctx context.Context, key string) error

func (*AccountUserDataCache) Get

func (a *AccountUserDataCache) Get(ctx context.Context, key string) ([]*idp.UserData, error)

func (*AccountUserDataCache) Set

func (a *AccountUserDataCache) Set(ctx context.Context, key string, value []*idp.UserData, expiration time.Duration) error

type Marshaler

type Marshaler interface {
	Get(ctx context.Context, key any, returnObj any) (any, error)
	Set(ctx context.Context, key, object any, options ...store.Option) error
	Delete(ctx context.Context, key any) error
}

type UserDataCache

type UserDataCache interface {
	Get(ctx context.Context, key string) (*idp.UserData, error)
	Set(ctx context.Context, key string, value *idp.UserData, expiration time.Duration) error
	Delete(ctx context.Context, key string) error
	GetUsers(ctx context.Context, key string) ([]*idp.UserData, error)
	SetUsers(ctx context.Context, key string, users []*idp.UserData, expiration time.Duration) error
}

UserDataCache is an interface that wraps the basic Get, Set and Delete methods for idp.UserData objects.

type UserDataCacheImpl

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

UserDataCacheImpl is a struct that implements the UserDataCache interface.

func NewUserDataCache

func NewUserDataCache(store store.StoreInterface) *UserDataCacheImpl

NewUserDataCache creates a new UserDataCacheImpl object.

func (*UserDataCacheImpl) Delete

func (u *UserDataCacheImpl) Delete(ctx context.Context, key string) error

func (*UserDataCacheImpl) Get

func (u *UserDataCacheImpl) Get(ctx context.Context, key string) (*idp.UserData, error)

func (*UserDataCacheImpl) GetUsers added in v0.63.0

func (u *UserDataCacheImpl) GetUsers(ctx context.Context, key string) ([]*idp.UserData, error)

func (*UserDataCacheImpl) Set

func (u *UserDataCacheImpl) Set(ctx context.Context, key string, value *idp.UserData, expiration time.Duration) error

func (*UserDataCacheImpl) SetUsers added in v0.63.0

func (u *UserDataCacheImpl) SetUsers(ctx context.Context, key string, users []*idp.UserData, expiration time.Duration) error

Jump to

Keyboard shortcuts

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