cache

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 9 Imported by: 7

README

cache

infra.Go cache module.

Documentation

Index

Constants

View Source
const (
	NAME = "CACHE"
)

Variables

View Source
var (
	ErrInvalidConnection = errors.New("Invalid cache connection.")
)

Functions

func Clear

func Clear(prefixs ...string) error

Clear 清理缓存

func ClearFrom

func ClearFrom(conn string, prefixs ...string) error

ClearFrom 从指定库清除缓存

func Delete

func Delete(key string) error

Delete 删除缓存

func DeleteFrom

func DeleteFrom(conn, key string) error

DeleteFrom 指定库删除缓存

func Exists

func Exists(key string) (bool, error)

Exists 是否存在缓存

func ExistsIn

func ExistsIn(conn, key string) (bool, error)

ExistsIn 指定库是否存在缓存

func Keys

func Keys(prefixs ...string) ([]string, error)

KeysFrom 获取Keys

func KeysFrom

func KeysFrom(conn string, prefixs ...string) ([]string, error)

KeysFrom 从指定库获取Keys

func Read

func Read(key string) (Map, error)

Read 读取缓存

func ReadData

func ReadData(key string) ([]byte, error)

ReadData 读取原始数据

func ReadDataFrom

func ReadDataFrom(conn, key string) ([]byte, error)

ReadDataFrom 指定库读取原始数据

func ReadFrom

func ReadFrom(conn, key string) (Map, error)

ReadFrom 指定库读取缓存

func Sequence

func Sequence(key string, start, step int64, expires ...time.Duration) (int64, error)

Sequence 生成序列

func SequenceOn

func SequenceOn(conn, key string, start, step int64, expires ...time.Duration) (int64, error)

SequenceOn 指定库生成序列

func Write

func Write(key string, value Map, expires ...time.Duration) error

Write 写缓存

func WriteData

func WriteData(key string, data []byte, expires ...time.Duration) error

WriteData 写缓存原始数据

func WriteDataTo

func WriteDataTo(conn, key string, data []byte, expires ...time.Duration) error

WriteDataTo 指定库写缓存原始数据

func WriteTo

func WriteTo(conn, key string, value Map, expires ...time.Duration) error

WriteTo 指定库写缓存

Types

type Config

type Config struct {
	Driver  string
	Weight  int
	Prefix  string
	Codec   string
	Expire  time.Duration
	Setting Map
}

type Configs

type Configs map[string]Config

type Connect

type Connect interface {
	Open() error
	Close() error

	Read(string) ([]byte, error)
	Write(key string, val []byte, expire time.Duration) error
	Exists(key string) (bool, error)
	Delete(key string) error
	Sequence(key string, start, step int64, expire time.Duration) (int64, error)
	Keys(prefix string) ([]string, error)
	Clear(prefix string) error
}

Connect 会话连接

type Driver

type Driver interface {
	Connect(*Instance) (Connect, error)
}

Driver 数据驱动

type Instance

type Instance struct {
	Name    string
	Config  Config
	Setting Map
	// contains filtered or unexported fields
}

type Module

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

func (*Module) Clear

func (this *Module) Clear(prefixs ...string) error

Clear 清里缓存

func (*Module) ClearFrom

func (this *Module) ClearFrom(conn string, prefixs ...string) error

Clear 按前缀清理缓存

func (*Module) Config

func (this *Module) Config(name string, config Config)

func (*Module) Configs

func (this *Module) Configs(name string, config Configs)

func (*Module) Configure

func (this *Module) Configure(global Map)

func (*Module) Connect

func (this *Module) Connect()

func (*Module) Delete

func (this *Module) Delete(key string) error

Delete 删除缓存

func (*Module) DeleteFrom

func (this *Module) DeleteFrom(conn, key string) error

Delete 从指定库删除缓存

func (*Module) Driver

func (this *Module) Driver(name string, driver Driver)

Driver 注册驱动

func (*Module) Exists

func (this *Module) Exists(key string) (bool, error)

Exists 判断缓存是否存在

func (*Module) ExistsIn

func (this *Module) ExistsIn(conn, key string) (bool, error)

ExistsIn 判断缓存是否存在指定库

func (*Module) Initialize

func (this *Module) Initialize()

func (*Module) Keys

func (this *Module) Keys(prefixs ...string) ([]string, error)

func (*Module) KeysFrom

func (this *Module) KeysFrom(conn string, prefixs ...string) ([]string, error)

Keys 获取所有前缀的KEYS

func (*Module) Launch

func (this *Module) Launch()

func (*Module) Read

func (this *Module) Read(key string) (Map, error)

Read 读取缓存

func (*Module) ReadData

func (this *Module) ReadData(key string) ([]byte, error)

ReadData 读取原始数据

func (*Module) ReadDataFrom

func (this *Module) ReadDataFrom(conn, key string) ([]byte, error)

ReadDataFrom 从指定库读原始数据

func (*Module) ReadFrom

func (this *Module) ReadFrom(conn, key string) (Map, error)

func (*Module) Register

func (this *Module) Register(name string, value Any)

func (*Module) Sequence

func (this *Module) Sequence(key string, start, step int64, expires ...time.Duration) (int64, error)

Sequence 生成编号

func (*Module) SequenceOn

func (this *Module) SequenceOn(conn, key string, start, step int64, expires ...time.Duration) (int64, error)

SequenceOn 指定库生成编号

func (*Module) Terminate

func (this *Module) Terminate()

func (*Module) Write

func (this *Module) Write(key string, val Map, expires ...time.Duration) error

Write 写缓存

func (*Module) WriteData

func (this *Module) WriteData(key string, data []byte, expires ...time.Duration) error

Write 写缓原始数据

func (*Module) WriteDataTo

func (this *Module) WriteDataTo(conn, key string, data []byte, expires ...time.Duration) error

func (*Module) WriteTo

func (this *Module) WriteTo(conn string, key string, val Map, expires ...time.Duration) error

Write 写缓存

Jump to

Keyboard shortcuts

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