Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v0.56.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: BSD-3-Clause, AGPL-3.0 Imports: 14 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
)
View Source
const RedisStoreEnvVar = "NB_IDP_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 NewStore

func NewStore(ctx context.Context, maxTimeout, cleanupInterval time.Duration) (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
}

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) Set

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

Jump to

Keyboard shortcuts

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