cache

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type RedisCache

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

func InitRedisCache

func InitRedisCache(ctx context.Context, redisAddress string, keyPrefix string) (*RedisCache, error)

func (*RedisCache) Get

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

func (*RedisCache) GetBool

func (cache *RedisCache) GetBool(ctx context.Context, key string) (bool, error)

func (*RedisCache) GetBytes

func (cache *RedisCache) GetBytes(ctx context.Context, key string) ([]byte, error)

func (*RedisCache) GetString

func (cache *RedisCache) GetString(ctx context.Context, key string) (string, error)

func (*RedisCache) GetUint64

func (cache *RedisCache) GetUint64(ctx context.Context, key string) (uint64, error)

func (*RedisCache) Set

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

func (*RedisCache) SetBool

func (cache *RedisCache) SetBool(ctx context.Context, key string, value bool, expiration time.Duration) error

func (*RedisCache) SetBytes

func (cache *RedisCache) SetBytes(ctx context.Context, key string, value []byte, expiration time.Duration) error

func (*RedisCache) SetString

func (cache *RedisCache) SetString(ctx context.Context, key, value string, expiration time.Duration) error

func (*RedisCache) SetUint64

func (cache *RedisCache) SetUint64(ctx context.Context, key string, value uint64, expiration time.Duration) error

type RemoteCache

type RemoteCache interface {
	Set(ctx context.Context, key string, value any, expiration time.Duration) error
	SetBytes(ctx context.Context, key string, value []byte, expiration time.Duration) error
	SetString(ctx context.Context, key, value string, expiration time.Duration) error
	SetUint64(ctx context.Context, key string, value uint64, expiration time.Duration) error
	SetBool(ctx context.Context, key string, value bool, expiration time.Duration) error

	Get(ctx context.Context, key string, returnValue any) (any, error)
	GetBytes(ctx context.Context, key string) ([]byte, error)
	GetString(ctx context.Context, key string) (string, error)
	GetUint64(ctx context.Context, key string) (uint64, error)
	GetBool(ctx context.Context, key string) (bool, error)
}

type TieredCache

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

Tiered cache is a cache implementation combining a local & remote cache

func NewTieredCache

func NewTieredCache(cacheSize int, redisAddress string, redisPrefix string) (*TieredCache, error)

func (*TieredCache) Get

func (cache *TieredCache) Get(key string, returnValue interface{}) (interface{}, error)

func (*TieredCache) Set

func (cache *TieredCache) Set(key string, value interface{}, expiration time.Duration) error

Jump to

Keyboard shortcuts

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