Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotSupport = errors.New("not support") ErrNotFound = errors.New("not found") )
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Store ¶
type Store interface { Name() string List(ctx context.Context, key string, opts ...Option) ([]*KV, error) Get(ctx context.Context, key string, opts ...Option) (*KV, error) Put(ctx context.Context, key string, value []byte) error Delete(ctx context.Context, key string, opts ...Option) error Exists(ctx context.Context, key string) (bool, error) Watch(ctx context.Context, key string, cb Callback, opts ...Option) error Close() error }
Store kv storage 主要用途:配置文件管理 推荐使用etcd,拥有mvcc控制 可以是本地文件存储,也可以是分布式kv存储,如etcd,consul,zookeeper consul的value限制不超过512kb
Key需要保持路径一样的形式,例如:path/to/key Get:通过Key查询是否有数据,没有数据返回nil List:通过前缀查询,空返回全部 Put: 通过key写入数据 Delete: 通过Key删除数据,如果有额外参数Prefix,则表示前缀匹配所有 Exists: 通过key判断是否存在 Watch: 监听key变化,如果有额外参数Prefix,则表示前缀匹配(监听目录) 注意: Get或者List查找不到数据时,会返回ErrNotFound错误
https://github.com/abronan/valkeyrie https://etcd.io/ https://www.consul.io/docs/agent/kv.html
Click to show internal directories.
Click to hide internal directories.