cache

package
v0.0.0-...-3be03c6 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("key not found")
	ErrExpired  = errors.New("key expired")
)

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	Get(ctx context.Context, key string) (interface{}, error)
	Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
	Delete(ctx context.Context, key string) error
	Has(ctx context.Context, key string) (bool, error)
}

type InMemoryCache

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

func NewInMemoryCache

func NewInMemoryCache() *InMemoryCache

func (*InMemoryCache) Delete

func (c *InMemoryCache) Delete(_ context.Context, key string) error

func (*InMemoryCache) Get

func (c *InMemoryCache) Get(_ context.Context, key string) (interface{}, error)

func (*InMemoryCache) Has

func (c *InMemoryCache) Has(ctx context.Context, key string) (bool, error)

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(_ context.Context, key string, value interface{}, ttl time.Duration) error

type RedisCache

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

func NewRedisCache

func NewRedisCache(addr, username, password string) (*RedisCache, error)

func (*RedisCache) Delete

func (c *RedisCache) Delete(ctx context.Context, key string) error

func (*RedisCache) Get

func (c *RedisCache) Get(ctx context.Context, key string) (interface{}, error)

func (*RedisCache) Has

func (c *RedisCache) Has(ctx context.Context, key string) (bool, error)

func (*RedisCache) Set

func (c *RedisCache) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error

Jump to

Keyboard shortcuts

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