cache

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func Close

func Close(ctx context.Context) error

Close is wrapper for global cache.Close.

func Delete

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

Delete is wrapper for global cache.Delete.

func Get

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

Get is wrapper for global cache.Get.

func Set

func Set(ctx context.Context, key string, value []byte, expire time.Duration) error

Set is wrapper for global cache.Set.

func SetGlobalCache

func SetGlobalCache(c Cache)

SetGlobalCache sets the global cache.

Types

type Cache

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

func GetGlobalCache

func GetGlobalCache() Cache

GetGlobalCache returns the global cache.

func NewMemoryCache

func NewMemoryCache() Cache

func NewRedisCache

func NewRedisCache(cli *redisv8.Client) Cache

NewRedisCache creates a new redisCache instance.

Jump to

Keyboard shortcuts

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