Documentation ¶
Index ¶
- Variables
- type ExpiringItem
- type Interface
- type Item
- type IterFunc
- type Set
- func (s *Set) Add(item Item) error
- func (s *Set) Clear() int
- func (s *Set) Each(fn IterFunc) error
- func (s *Set) Get(key string) (Item, error)
- func (s *Set) In(key string) bool
- func (s *Set) Len() int
- func (s *Set) ListPrefix(prefix string) []Item
- func (s *Set) Remove(key string) error
- func (s *Set) Replace(oldKey string, item Item) error
- func (s *Set) Set(item Item) error
- type StringItem
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCollision = errors.New("key already exists")
Returned when an added key already exists in the set.
View Source
var ErrMissing = errors.New("item does not exist")
Returned when a requested item does not exist in the set.
View Source
var ErrNil = errors.New("item value must not be nil")
Returned when a nil item is added. Nil values are considered expired and invalid.
View Source
var ZeroValue = struct{}{}
ZeroValue can be used when we only care about the key, not about the value.
Functions ¶
This section is empty.
Types ¶
type ExpiringItem ¶
func (*ExpiringItem) Expired ¶
func (item *ExpiringItem) Expired() bool
func (*ExpiringItem) Value ¶
func (item *ExpiringItem) Value() interface{}
type Interface ¶ added in v1.10.1
type Interface interface { Clear() int Each(fn IterFunc) error // Add only if the item does not already exist Add(item Item) error // Set item, override if it already exists Set(item Item) error Get(key string) (Item, error) In(key string) bool Len() int ListPrefix(prefix string) []Item Remove(key string) error Replace(oldKey string, item Item) error }
Interface is the Set interface
type Item ¶
type Item interface { Key() string Value() interface{} }
Interface for an item storeable in the set
type Set ¶
func (*Set) Each ¶
Each loops over every item while holding a read lock and applies fn to each element.
func (*Set) ListPrefix ¶
ListPrefix returns a list of items with a prefix, normalized. TODO: Add trie for efficient prefix lookup
type StringItem ¶
type StringItem string
func (StringItem) Key ¶
func (item StringItem) Key() string
func (StringItem) Value ¶
func (item StringItem) Value() interface{}
Click to show internal directories.
Click to hide internal directories.