cache

package
v0.0.0-...-3839eb7 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateKey = errors.New("duplicate key")
)

Functions

func APIKeyCacheKey

func APIKeyCacheKey(userId, keyId string) string

func AccessTokenCacheKey

func AccessTokenCacheKey(tokenId string) string

func CodeCacheKey

func CodeCacheKey(code string) string

func RefreshTokenCacheKey

func RefreshTokenCacheKey(tokenId string) string

Types

type EmailCodeCache

type EmailCodeCache interface {
	Get(ctx context.Context, code string) (string, error)
	Set(ctx context.Context, code string, email string, expire time.Duration) error
	Del(ctx context.Context, code string) error
	Check(ctx context.Context, code string) (string, error)
}

type KeyCache

type KeyCache interface {
	Key(userId, keyId string) string
	TTL(ctx context.Context, userId, keyId string) (time.Duration, error)
	Get(ctx context.Context, userId, keyId string) (entity.APIKey, bool, error)
	Find(ctx context.Context, keyId string) (entity.APIKey, bool, error)
	Set(ctx context.Context, apikey entity.APIKey, ttl time.Duration) error
	Del(ctx context.Context, userId, keyId string) error
	List(ctx context.Context, userId string) ([]entity.APIKey, error)
}

type RedisApiKeyCache

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

func NewAPIKeyCache

func NewAPIKeyCache(client *redis.Client) RedisApiKeyCache

func (RedisApiKeyCache) Del

func (r RedisApiKeyCache) Del(ctx context.Context, userId, keyId string) error

func (RedisApiKeyCache) Find

func (r RedisApiKeyCache) Find(ctx context.Context, keyId string) (entity.APIKey, bool, error)

func (RedisApiKeyCache) Get

func (r RedisApiKeyCache) Get(ctx context.Context, userId, keyId string) (entity.APIKey, bool, error)

func (RedisApiKeyCache) Key

func (r RedisApiKeyCache) Key(userId, keyId string) string

func (RedisApiKeyCache) List

func (r RedisApiKeyCache) List(ctx context.Context, userId string) ([]entity.APIKey, error)

func (RedisApiKeyCache) Set

func (r RedisApiKeyCache) Set(ctx context.Context, apikey entity.APIKey, ttl time.Duration) error

func (RedisApiKeyCache) TTL

func (r RedisApiKeyCache) TTL(ctx context.Context, userId, keyId string) (time.Duration, error)

type RedisEmailCodeCache

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

func NewRedisEmailCodeCache

func NewRedisEmailCodeCache(source *data.DataSource) RedisEmailCodeCache

func (RedisEmailCodeCache) Check

func (c RedisEmailCodeCache) Check(ctx context.Context, code string) (string, error)

Check get and remove

func (RedisEmailCodeCache) Del

func (c RedisEmailCodeCache) Del(ctx context.Context, code string) error

func (RedisEmailCodeCache) Get

func (c RedisEmailCodeCache) Get(ctx context.Context, code string) (string, error)

func (RedisEmailCodeCache) Set

func (c RedisEmailCodeCache) Set(ctx context.Context, code string, email string, expire time.Duration) error

type RedisTokenCache

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

func NewAccessTokenCache

func NewAccessTokenCache(d *data.DataSource) RedisTokenCache

func NewRefreshTokenCache

func NewRefreshTokenCache(d *data.DataSource) RedisTokenCache

func (RedisTokenCache) Del

func (t RedisTokenCache) Del(ctx context.Context, tokenId string) error

func (RedisTokenCache) Get

func (t RedisTokenCache) Get(ctx context.Context, tokenId string) (string, bool, error)

func (RedisTokenCache) Key

func (t RedisTokenCache) Key(tokenId string) string

func (RedisTokenCache) Set

func (t RedisTokenCache) Set(ctx context.Context, tokenId string, token string, expire time.Duration) error

func (RedisTokenCache) TTL

func (t RedisTokenCache) TTL(ctx context.Context, tokenId string) (time.Duration, error)

type TokenCache

type TokenCache interface {
	TTL(ctx context.Context, tokenId string) (time.Duration, error)
	Key(tokenId string) string
	Get(ctx context.Context, tokenId string) (string, bool, error)
	Set(ctx context.Context, tokenId string, token string, expire time.Duration) error
	Del(ctx context.Context, tokenId string) error
}

Jump to

Keyboard shortcuts

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