services

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoneDuration = time.Duration(-1)
)

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")
View Source
var ErrTypeNotOk = errors.New("val type not ok")

Functions

func NewRedisCache

func NewRedisCache(params ...interface{}) (interface{}, error)

Types

type RedisCache

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

func (*RedisCache) Calc

func (r *RedisCache) Calc(ctx context.Context, key string, step int64) (int64, error)

func (*RedisCache) Decrement

func (r *RedisCache) Decrement(ctx context.Context, key string) (int64, error)

func (*RedisCache) Del

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

func (*RedisCache) DelMany

func (r *RedisCache) DelMany(ctx context.Context, keys []string) error

func (*RedisCache) GetMany

func (r *RedisCache) GetMany(ctx context.Context, keys []string) (map[string]string, error)

func (*RedisCache) GetObj

func (r *RedisCache) GetObj(ctx context.Context, key string, model interface{}) error

GetObj 获取某个key对应的对象, 对象必须实现 https://pkg.go.dev/encoding#BinaryUnMarshaler

func (*RedisCache) GetTTL

func (r *RedisCache) GetTTL(ctx context.Context, key string) (time.Duration, error)

func (*RedisCache) Increment

func (r *RedisCache) Increment(ctx context.Context, key string) (int64, error)

func (*RedisCache) Remember

func (r *RedisCache) Remember(ctx context.Context, key string, timeout time.Duration, rememberFucn contract.RememberFunc, obj interface{}) error

func (*RedisCache) Set

func (r *RedisCache) Set(ctx context.Context, key string, val string, timeout time.Duration) error

func (*RedisCache) SetForever

func (r *RedisCache) SetForever(ctx context.Context, key string, val string) error

func (*RedisCache) SetForeverObj

func (r *RedisCache) SetForeverObj(ctx context.Context, key string, val interface{}) error

func (*RedisCache) SetMany

func (r *RedisCache) SetMany(ctx context.Context, data map[string]string, timeout time.Duration) error

func (*RedisCache) SetObj

func (r *RedisCache) SetObj(ctx context.Context, key string, val interface{}, timeout time.Duration) error

func (*RedisCache) SetTTL

func (r *RedisCache) SetTTL(ctx context.Context, key string, timeout time.Duration) error

Jump to

Keyboard shortcuts

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