cache

package
v1.1.59 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory

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

func NewMemory

func NewMemory() *Memory

NewMemory memory模式

func (*Memory) Decrease

func (m *Memory) Decrease(_ context.Context, key string) error

func (*Memory) Del

func (m *Memory) Del(_ context.Context, key string) error

func (*Memory) Exists added in v1.1.51

func (m *Memory) Exists(_ context.Context, key string) (bool, error)

func (*Memory) Expire

func (m *Memory) Expire(_ context.Context, key string, dur time.Duration) error

func (*Memory) Get

func (m *Memory) Get(_ context.Context, key string) (string, error)

func (*Memory) HashDel

func (m *Memory) HashDel(_ context.Context, hk, key string) error

func (*Memory) HashGet

func (m *Memory) HashGet(_ context.Context, hk, key string) (string, error)

func (*Memory) HashSet added in v1.1.51

func (m *Memory) HashSet(_ context.Context, hk, key string, val interface{}) error

func (*Memory) IncrBy added in v1.1.51

func (m *Memory) IncrBy(_ context.Context, key string, n int64) (int64, error)

func (*Memory) Increase

func (m *Memory) Increase(_ context.Context, key string) error

func (*Memory) RunScript added in v1.1.51

func (m *Memory) RunScript(_ context.Context, script interface{}, keys []string, args ...interface{}) (interface{}, error)

func (*Memory) Set

func (m *Memory) Set(_ context.Context, key string, val interface{}, expire int) error

func (*Memory) SetNX added in v1.1.51

func (m *Memory) SetNX(_ context.Context, key string, val interface{}, expire int) (bool, error)

SetNX atomically sets a value only if the key does not exist. The entire check-and-set is protected by a write lock to prevent TOCTOU races.

func (*Memory) String

func (*Memory) String() string

func (*Memory) TTL added in v1.1.51

func (m *Memory) TTL(_ context.Context, key string) (time.Duration, error)

type Redis

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

Redis cache implement

func NewRedis

func NewRedis(client *redis.Client, options *redis.Options) (*Redis, error)

func (*Redis) Close added in v1.1.51

func (r *Redis) Close() error

Close releases the redis connection

func (*Redis) Decrease

func (r *Redis) Decrease(ctx context.Context, key string) error

func (*Redis) Del

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

func (*Redis) Exists added in v1.1.51

func (r *Redis) Exists(ctx context.Context, key string) (bool, error)

func (*Redis) Expire

func (r *Redis) Expire(ctx context.Context, key string, dur time.Duration) error

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, key string) (string, error)

func (*Redis) GetClient

func (r *Redis) GetClient() *redis.Client

GetClient exposes the underlying redis client

func (*Redis) HashDel

func (r *Redis) HashDel(ctx context.Context, hk, key string) error

func (*Redis) HashGet

func (r *Redis) HashGet(ctx context.Context, hk, key string) (string, error)

func (*Redis) HashSet added in v1.1.51

func (r *Redis) HashSet(ctx context.Context, hk, key string, val interface{}) error

func (*Redis) IncrBy added in v1.1.51

func (r *Redis) IncrBy(ctx context.Context, key string, n int64) (int64, error)

func (*Redis) Increase

func (r *Redis) Increase(ctx context.Context, key string) error

func (*Redis) RunScript added in v1.1.51

func (r *Redis) RunScript(ctx context.Context, script interface{}, keys []string, args ...interface{}) (interface{}, error)

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, key string, val interface{}, expire int) error

func (*Redis) SetNX added in v1.1.51

func (r *Redis) SetNX(ctx context.Context, key string, val interface{}, expire int) (bool, error)

func (*Redis) String

func (*Redis) String() string

func (*Redis) TTL added in v1.1.51

func (r *Redis) TTL(ctx context.Context, key string) (time.Duration, error)

Jump to

Keyboard shortcuts

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