Documentation ¶
Index ¶
- Variables
- type BackendType
- type JSONStoreWithSTM
- type JSONStoreWithSTMImpl
- type JSONStoreWithWatch
- type JSONStoreWithWatchImpl
- type JsonStore
- type JsonStoreImpl
- func (j *JsonStoreImpl) ForEach(ctx context.Context, prefix string, object interface{}, ...) error
- func (j *JsonStoreImpl) ForEachRaw(ctx context.Context, prefix string, handle func(string, []byte) error) error
- func (j *JsonStoreImpl) Get(ctx context.Context, key string, object interface{}) error
- func (j *JsonStoreImpl) IncludeSTM() JSONStoreWithSTM
- func (j *JsonStoreImpl) IncludeWatch() JSONStoreWithWatch
- func (j *JsonStoreImpl) ListKeys(ctx context.Context, prefix string) ([]string, error)
- func (j *JsonStoreImpl) Notfound(ctx context.Context, key string) (bool, error)
- func (j *JsonStoreImpl) PrefixRemove(ctx context.Context, prefix string) (int, error)
- func (j *JsonStoreImpl) Put(ctx context.Context, key string, object interface{}) error
- func (j *JsonStoreImpl) PutWithOption(ctx context.Context, key string, object interface{}, opts []interface{}) (interface{}, error)
- func (j *JsonStoreImpl) Remove(ctx context.Context, key string, object interface{}) error
- type Option
- type OptionOperator
- func UseCacheEtcdStore(ctx context.Context, etcdDir string, cap int) OptionOperator
- func UseEtcdStore() OptionOperator
- func UseLruStore(cap int) OptionOperator
- func UseMemEtcdStore(ctx context.Context, etcdDir string, ...) OptionOperator
- func UseMemStore() OptionOperator
- func UseTimeoutStore(timeout int) OptionOperator
Constants ¶
This section is empty.
Variables ¶
View Source
var (
NotFoundErr = errors.New("not found")
)
Functions ¶
This section is empty.
Types ¶
type BackendType ¶
type BackendType = int
const ( EtcdStore BackendType = iota MemStore MemEtcdStore CacheEtcdStore )
type JSONStoreWithSTM ¶
type JSONStoreWithSTM interface { JsonStore stm.JSONStoreSTM }
type JSONStoreWithSTMImpl ¶
type JSONStoreWithSTMImpl struct { JsonStore // contains filtered or unexported fields }
func (*JSONStoreWithSTMImpl) NewSTM ¶
func (j *JSONStoreWithSTMImpl) NewSTM(f func(stm stm.JSONStoreSTMOP) error) error
type JSONStoreWithWatch ¶
type JSONStoreWithWatchImpl ¶
type JSONStoreWithWatchImpl struct { JsonStore // contains filtered or unexported fields }
func (*JSONStoreWithWatchImpl) Watch ¶
func (j *JSONStoreWithWatchImpl) Watch(ctx context.Context, key string, isPrefix bool, filterDelete bool, keyonly bool, object interface{}, handle func(string, interface{}, storetypes.ChangeType) error) error
TODO: refactor this method, use options, instead of so many bool values
type JsonStore ¶
type JsonStore interface { Put(ctx context.Context, key string, object interface{}) error PutWithOption(ctx context.Context, key string, object interface{}, opts []interface{}) (interface{}, error) Get(ctx context.Context, key string, object interface{}) error Remove(ctx context.Context, key string, object interface{}) error PrefixRemove(ctx context.Context, prefix string) (int, error) ForEach(ctx context.Context, prefix string, object interface{}, handle func(string, interface{}) error) error ForEachRaw(ctx context.Context, prefix string, handle func(string, []byte) error) error ListKeys(ctx context.Context, prefix string) ([]string, error) Notfound(ctx context.Context, key string) (bool, error) IncludeSTM() JSONStoreWithSTM IncludeWatch() JSONStoreWithWatch }
func New ¶
func New(opts ...OptionOperator) (JsonStore, error)
type JsonStoreImpl ¶
type JsonStoreImpl struct {
// contains filtered or unexported fields
}
func (*JsonStoreImpl) ForEachRaw ¶
func (*JsonStoreImpl) Get ¶
func (j *JsonStoreImpl) Get(ctx context.Context, key string, object interface{}) error
func (*JsonStoreImpl) IncludeSTM ¶
func (j *JsonStoreImpl) IncludeSTM() JSONStoreWithSTM
func (*JsonStoreImpl) IncludeWatch ¶
func (j *JsonStoreImpl) IncludeWatch() JSONStoreWithWatch
func (*JsonStoreImpl) PrefixRemove ¶
func (*JsonStoreImpl) Put ¶
func (j *JsonStoreImpl) Put(ctx context.Context, key string, object interface{}) error
func (*JsonStoreImpl) PutWithOption ¶
func (j *JsonStoreImpl) PutWithOption(ctx context.Context, key string, object interface{}, opts []interface{}) (interface{}, error)
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
func (*Option) Apply ¶
func (op *Option) Apply(opts []OptionOperator)
func (*Option) GetBackend ¶
func (op *Option) GetBackend() (storetypes.Store, error)
type OptionOperator ¶
type OptionOperator func(*Option)
func UseCacheEtcdStore ¶
func UseCacheEtcdStore(ctx context.Context, etcdDir string, cap int) OptionOperator
func UseEtcdStore ¶
func UseEtcdStore() OptionOperator
func UseLruStore ¶
func UseLruStore(cap int) OptionOperator
func UseMemEtcdStore ¶
func UseMemEtcdStore(ctx context.Context, etcdDir string, cb func(k string, v interface{}, t storetypes.ChangeType), cbobj interface{}) OptionOperator
func UseMemStore ¶
func UseMemStore() OptionOperator
Directories ¶
Path | Synopsis |
---|---|
LRU + Watch
|
LRU + Watch |
Package etcd 是 jsonstore 使用 etcd 作为 backend 的实现
|
Package etcd 是 jsonstore 使用 etcd 作为 backend 的实现 |
内存 + etcd, 内存中的数据自动与 etcd 中同步
|
内存 + etcd, 内存中的数据自动与 etcd 中同步 |
Package stm impl jsonstore stm with etcd concurrency package
|
Package stm impl jsonstore stm with etcd concurrency package |
Package storetypes define jsonstore public types
|
Package storetypes define jsonstore public types |
重复插入key相同的value, 不更新该key的deadline
|
重复插入key相同的value, 不更新该key的deadline |
Click to show internal directories.
Click to hide internal directories.