store

package
v2.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeStore

type FakeStore struct {
}

func NewFakeStore

func NewFakeStore() *FakeStore

func (*FakeStore) Get

func (f *FakeStore) Get(key string) (string, error)

返回 key 对应的数据

func (*FakeStore) Range

func (f *FakeStore) Range(pattern string) ([]string, error)

遍历返回 pattern 开头的所有 key 数据

func (*FakeStore) RangeRemove

func (f *FakeStore) RangeRemove(pattern string) error

遍历删除 pattern 开头的所有 key 数据

func (*FakeStore) Remove

func (f *FakeStore) Remove(key string) error

删除 key 和 key 对应的数据

func (*FakeStore) Set

func (f *FakeStore) Set(key string, value string) error

设置 key 对应的数据

type FileStore

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

func (*FileStore) Get

func (s *FileStore) Get(key string) (string, error)

func (*FileStore) Range

func (s *FileStore) Range(pattern string) ([]string, error)

func (*FileStore) RangeRemove

func (s *FileStore) RangeRemove(pattern string) error

func (*FileStore) Remove

func (s *FileStore) Remove(key string) error

func (*FileStore) Set

func (s *FileStore) Set(key string, value string) error

type Store

type Store interface {
	// 返回 key 对应的数据
	Get(key string) (string, error)
	// 设置 key 对应的数据
	Set(key string, value string) error
	// 删除 key 和 key 对应的数据
	Remove(key string) error
	// 遍历返回 pattern 开头的所有 key 数据
	Range(pattern string) ([]string, error)
	// 遍历删除 pattern 开头的所有 key 数据
	RangeRemove(pattern string) error
}

func NewFileStore

func NewFileStore(path string) (Store, error)

Jump to

Keyboard shortcuts

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