Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCASCond = errorf("CAS COND FAILED")
)
errors
Functions ¶
This section is empty.
Types ¶
type KV ¶
type KV interface {
Delete(k string)
Get(k string) (v interface{}, ok bool)
Put(k string, v interface{}, options ...PutOption) error
Take(k string) (v interface{}, ok bool)
Stop()
}
KV is a registry for values (like/is a concurrent map) with timeout and sliding timeout
func New ¶
New creates a new *store, onExpire is for notification (must be fast).
Example ¶
key := "KEY"
value := "VALUE"
kv := New(time.Millisecond * 10)
defer kv.Stop()
kv.Put(key, value)
v, ok := kv.Get(key)
if !ok {
// ...
}
fmt.Println(key, v)
kv.Delete(key)
_, ok = kv.Get(key)
fmt.Println(ok)
Output: KEY VALUE false
Click to show internal directories.
Click to hide internal directories.