cache

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cache provides the cache management interface define

Package cache implements a distributed cache Interface redis_remote_cache.go implements a distributed cache with redis

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("cache: key is missing")

ErrCacheMiss cache miss error if Get() method return this error, means key is not exist

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Set the key value to cache
	Set(ctx context.Context, k string, v []byte, ttl time.Duration) error
	// Get the key value from cache
	Get(ctx context.Context, k string) ([]byte, error)
	// Del delete the key from cache
	Del(ctx context.Context, k string) error
	// Close the cache
	Close() error
}

Interface cache interface

func NewLocalCache

func NewLocalCache(c *configs.LocalCacheConfig) (Interface, error)

NewLocalCache create a local cache capacity is the cache capacity ttl is the time to live

func NewProxy

func NewProxy(c *configs.CacheConfig) (Interface, error)

NewProxy creates a new cache proxy, which contains a distributed cache and a local cache

func NewRedisRemoteCache

func NewRedisRemoteCache(c *configs.RedisConfig) Interface

NewRedisRemoteCache returns a new redis cache

Jump to

Keyboard shortcuts

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