cache

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache structure

func (*Cache) Decr

func (c *Cache) Decr(ctx context.Context, key string) (int64, error)

Decr ...

func (*Cache) DecrBy

func (c *Cache) DecrBy(ctx context.Context, key string, value int64) (int64, error)

DecrBy ...

func (*Cache) Delete

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

Delete ...

func (*Cache) Exists

func (c *Cache) Exists(ctx context.Context, keys ...string) int64

func (*Cache) Get

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

Get reads value by key

func (*Cache) GetSMembers

func (c *Cache) GetSMembers(ctx context.Context, key string) ([]string, error)

func (*Cache) GetVal

func (c *Cache) GetVal(ctx context.Context, key string) (string, error)

GetVal reads value by key

func (*Cache) Incr

func (c *Cache) Incr(ctx context.Context, key string) (int64, error)

Incr ...

func (*Cache) IncrBy

func (c *Cache) IncrBy(ctx context.Context, key string, value int64) (int64, error)

IncrBy ...

func (*Cache) LGet

func (c *Cache) LGet(ctx context.Context, key string) ([]byte, error)

LGet ...

func (*Cache) LLen

func (c *Cache) LLen(ctx context.Context, key string) (int64, error)

LLen ...

func (*Cache) LList

func (c *Cache) LList(ctx context.Context, key string) ([]string, error)

LList ...

func (*Cache) LRange

func (c *Cache) LRange(ctx context.Context, key string, from int, to int) ([]string, error)

LRange ...

func (*Cache) LSet

func (c *Cache) LSet(ctx context.Context, key string, val []byte) error

LSet ...

func (*Cache) RSet

func (c *Cache) RSet(ctx context.Context, key string, val []byte) error

RSet ...

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key string, value []byte) error

Set sets value by key

func (*Cache) SetExpireTime

func (c *Cache) SetExpireTime(ctx context.Context, key string, seconds int64) error

func (*Cache) SetNX

func (c *Cache) SetNX(ctx context.Context, key string, seconds int64, data interface{}) (bool, error)

func (*Cache) SetObject

func (c *Cache) SetObject(ctx context.Context, key string, val interface{}, duration time.Duration) error

func (*Cache) SetSAdd

func (c *Cache) SetSAdd(ctx context.Context, key string, members ...interface{}) error

func (*Cache) SetVal

func (c *Cache) SetVal(ctx context.Context, key string, value string) error

SetVal set value by key

func (*Cache) SetWithDuration

func (c *Cache) SetWithDuration(ctx context.Context, key string, value []byte, duration time.Duration) error

SetWithDuration ...

func (*Cache) ZAdd

func (c *Cache) ZAdd(ctx context.Context, key string, score float64, member string) error

ZAdd ...

func (*Cache) ZIncrBy

func (c *Cache) ZIncrBy(ctx context.Context, key string, increment float64, member string) error

ZIncrBy ...

func (*Cache) ZRange

func (c *Cache) ZRange(ctx context.Context, key string, start int64, stop int64) ([]string, error)

ZRange ...

func (*Cache) ZRemRangeByRank

func (c *Cache) ZRemRangeByRank(ctx context.Context, key string, start int64, stop int64) error

ZRemRangeByRank ...

func (*Cache) ZRevRangeWithScores

func (c *Cache) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error)

ZRevRangeWithScores ...

func (*Cache) ZRevRank

func (c *Cache) ZRevRank(ctx context.Context, key string, member string) (int64, error)

ZRevRank ...

func (*Cache) ZScore

func (c *Cache) ZScore(ctx context.Context, key string, member string) (float64, error)

ZScore ...

type ICache

type ICache interface {
	Get(ctx context.Context, key string) ([]byte, error)
	Set(ctx context.Context, key string, value []byte) error
	SetObject(ctx context.Context, key string, val interface{}, duration time.Duration) error
	Delete(ctx context.Context, key string) error
	SetWithDuration(ctx context.Context, key string, value []byte, duration time.Duration) error
	SetExpireTime(ctx context.Context, key string, seconds int64) error
	Exists(ctx context.Context, keys ...string) int64

	LSet(ctx context.Context, key string, vals []byte) error
	RSet(ctx context.Context, key string, val []byte) error
	LLen(ctx context.Context, key string) (int64, error)
	LGet(ctx context.Context, key string) ([]byte, error)
	LList(ctx context.Context, key string) ([]string, error)
	Incr(ctx context.Context, key string) (int64, error)
	Decr(ctx context.Context, key string) (int64, error)
	DecrBy(ctx context.Context, key string, value int64) (int64, error)
	IncrBy(ctx context.Context, key string, value int64) (int64, error)

	SetVal(ctx context.Context, key string, value string) error
	GetVal(ctx context.Context, key string) (string, error)
	LRange(ctx context.Context, key string, from int, to int) ([]string, error)
	ZAdd(ctx context.Context, key string, score float64, member string) error
	ZRange(ctx context.Context, key string, start int64, stop int64) ([]string, error)
	ZRemRangeByRank(ctx context.Context, key string, start int64, stop int64) error
	ZIncrBy(ctx context.Context, key string, increment float64, member string) error
	ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error)
	ZRevRank(ctx context.Context, key string, member string) (int64, error)
	ZScore(ctx context.Context, key string, member string) (float64, error)

	GetSMembers(ctx context.Context, key string) ([]string, error)
	SetSAdd(ctx context.Context, key string, members ...interface{}) error
	SetNX(ctx context.Context, key string, seconds int64, data interface{}) (bool, error)
}

ICache interface for plain cache

func NewCache

func NewCache(rc *redis.Client, cacheTime time.Duration) ICache

NewCache initializes Cache

Jump to

Keyboard shortcuts

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