cache

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultExpiry = time.Minute * 30
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(context.Context, string) ([]byte, error)
	Set(context.Context, string, []byte, time.Duration) error
	Del(context.Context, string) error
}

type Encrypted

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

func NewEncrypted

func NewEncrypted(aes *crypto.AES, inner Cache) *Encrypted

func (*Encrypted) Del

func (e *Encrypted) Del(ctx context.Context, key string) error

func (*Encrypted) Get

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

func (*Encrypted) Set

func (e *Encrypted) Set(ctx context.Context, key string, value []byte, expiry time.Duration) error

type InMemory

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

func NewInMemory

func NewInMemory(numCounters, maxCost int64) (*InMemory, error)

func (*InMemory) Del

func (c *InMemory) Del(_ context.Context, key string) error

func (*InMemory) Get

func (c *InMemory) Get(_ context.Context, key string) ([]byte, error)

func (*InMemory) Set

func (c *InMemory) Set(_ context.Context, key string, value []byte, expiry time.Duration) error

type Redis

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

func NewRedis

func NewRedis(cache *redis.Client) *Redis

func (*Redis) Del

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

func (*Redis) Get

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

func (*Redis) Set

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

Jump to

Keyboard shortcuts

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