xkv

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	kv.Store
	// contains filtered or unexported fields
}

Store 键值存取器

func NewStore

func NewStore(c kv.KvConf) *Store

NewStore 新建键值存取器

func (*Store) GetBytes

func (s *Store) GetBytes(key string) ([]byte, error)

GetBytes 返回给定 key 所关联的 []byte 值

func (*Store) GetBytesCtx

func (s *Store) GetBytesCtx(ctx context.Context, key string) ([]byte, error)

GetBytesCtx 返回给定 key 所关联的 []byte 值

func (*Store) GetDel

func (s *Store) GetDel(key string) (string, error)

GetDel 返回并删除给定 key 所关联的 string 值

func (*Store) GetDelCtx

func (s *Store) GetDelCtx(ctx context.Context, key string) (string, error)

GetDelCtx 返回并删除给定 key 所关联的 string 值

func (*Store) GetInt

func (s *Store) GetInt(key string) (int, error)

GetInt 返回给定 key 所关联的 int 值

func (*Store) GetInt64

func (s *Store) GetInt64(key string) (int64, error)

GetInt64 返回给定 key 所关联的 int64 值

func (*Store) GetInt64Ctx

func (s *Store) GetInt64Ctx(ctx context.Context, key string) (int64, error)

GetInt64Ctx 返回给定 key 所关联的 int64 值

func (*Store) GetIntCtx

func (s *Store) GetIntCtx(ctx context.Context, key string) (int, error)

GetIntCtx 返回给定 key 所关联的 int 值

func (*Store) Read

func (s *Store) Read(key string, obj any) (bool, error)

Read 将给定 key 所关联的值反序列化到 obj 对象

返回 false 时代表给定 key 不存在

func (*Store) ReadCtx

func (s *Store) ReadCtx(ctx context.Context, key string, obj any) (bool, error)

ReadCtx 将给定 key 所关联的值反序列化到 obj 对象

返回 false 时代表给定 key 不存在

func (*Store) ReadOrGet

func (s *Store) ReadOrGet(key string, obj any, gf func() (any, error), seconds ...int) error

ReadOrGet 将给定 key 所关联的值反序列化到 obj 对象

若给定 key 不存在则调用数据获取函数,调用成功时赋值至 obj 对象,并将其序列化后关联到给定 key
seconds 为 key 的过期时间(秒)

func (*Store) ReadOrGetCtx

func (s *Store) ReadOrGetCtx(ctx context.Context, key string, obj any, gf func(ctx context.Context) (any, error), seconds ...int) error

ReadOrGetCtx 将给定 key 所关联的值反序列化到 obj 对象

若给定 key 不存在则调用数据获取函数,调用成功时赋值至 obj 对象,并将其序列化后关联到给定 key
seconds 为 key 的过期时间(秒)

func (*Store) SetInt

func (s *Store) SetInt(key string, value int, seconds ...int) error

SetInt 将 int value 关联到给定 key,seconds 为 key 的过期时间(秒)

func (*Store) SetInt64

func (s *Store) SetInt64(key string, value int64, seconds ...int) error

SetInt64 将 int64 value 关联到给定 key,seconds 为 key 的过期时间(秒)

func (*Store) SetInt64Ctx

func (s *Store) SetInt64Ctx(ctx context.Context, key string, value int64, seconds ...int) error

SetInt64Ctx 将 int64 value 关联到给定 key,seconds 为 key 的过期时间(秒)

func (*Store) SetIntCtx

func (s *Store) SetIntCtx(ctx context.Context, key string, value int, seconds ...int) error

SetIntCtx 将 int value 关联到给定 key,seconds 为 key 的过期时间(秒)

func (*Store) SetString

func (s *Store) SetString(key, value string, seconds ...int) error

SetString 将 string value 关联到给定 key,seconds 为 key 的过期时间(秒)

func (*Store) SetStringCtx

func (s *Store) SetStringCtx(ctx context.Context, key, value string, seconds ...int) error

SetStringCtx 将 string value 关联到给定 key,seconds 为 key 的过期时间(秒)

func (*Store) Write

func (s *Store) Write(key string, obj any, seconds ...int) error

Write 将对象 obj 序列化后关联到给定 key,seconds 为 key 的过期时间(秒)

func (*Store) WriteCtx

func (s *Store) WriteCtx(ctx context.Context, key string, obj any, seconds ...int) error

WriteCtx 将对象 obj 序列化后关联到给定 key,seconds 为 key 的过期时间(秒)

Jump to

Keyboard shortcuts

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