cache

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMiss = errors.New("cache miss")
)

Functions

func AutharaUserKey

func AutharaUserKey(userID string) string

func RateLimitKey

func RateLimitKey(kind, scope, value string) string

Types

type Cache

type Cache interface {
	Get(ctx context.Context, key string) ([]byte, error)
	Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
	Delete(ctx context.Context, key string) error
	Close() error
}

type Counter

type Counter interface {
	Increment(ctx context.Context, key string, ttl time.Duration) (count int64, remainingTTL time.Duration, err error)
}

type Noop

type Noop struct{}

func NewNoop

func NewNoop() *Noop

func (*Noop) Close

func (n *Noop) Close() error

func (*Noop) Delete

func (n *Noop) Delete(ctx context.Context, key string) error

func (*Noop) Get

func (n *Noop) Get(ctx context.Context, key string) ([]byte, error)

func (*Noop) Set

func (n *Noop) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

type Redis

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

func NewRedis

func NewRedis(cfg RedisConfig) (*Redis, error)

func (*Redis) Close

func (r *Redis) Close() error

func (*Redis) Delete

func (r *Redis) Delete(ctx context.Context, key string) error

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, key string) ([]byte, error)

func (*Redis) Increment

func (r *Redis) Increment(
	ctx context.Context,
	key string,
	ttl time.Duration,
) (count int64, remainingTTL time.Duration, err error)

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

type RedisConfig

type RedisConfig struct {
	Host     string
	Port     int
	Password string
	DB       int
}

Jump to

Keyboard shortcuts

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