Documentation ¶
Index ¶
- Variables
- type ExpiringItem
- 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
- 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.
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 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.