This section is empty.


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.


          This section is empty.


          type ExpiringItem

          type ExpiringItem struct {

          func (*ExpiringItem) Expired

          func (item *ExpiringItem) Expired() bool

          func (*ExpiringItem) Value

          func (item *ExpiringItem) Value() interface{}

          type Interface

          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

              func Expire

              func Expire(item Item, d time.Duration) Item

              func Itemize

              func Itemize(key string, value interface{}) Item

              type IterFunc

              type IterFunc func(key string, item Item) error

              type Set

              type Set struct {
              	// contains filtered or unexported fields

              func New

              func New() *Set

                New creates a new set with case-insensitive keys

                func (*Set) Add

                func (s *Set) Add(item Item) error

                  Add item to this set if it does not exist already.

                  func (*Set) Clear

                  func (s *Set) Clear() int

                    Clear removes all items and returns the number removed.

                    func (*Set) Each

                    func (s *Set) Each(fn IterFunc) error

                      Each loops over every item while holding a read lock and applies fn to each element.

                      func (*Set) Get

                      func (s *Set) Get(key string) (Item, error)

                        Get returns an item with the given key.

                        func (*Set) In

                        func (s *Set) In(key string) bool

                          In checks if an item exists in this set.

                          func (*Set) Len

                          func (s *Set) Len() int

                            Len returns the size of the set right now.

                            func (*Set) ListPrefix

                            func (s *Set) ListPrefix(prefix string) []Item

                              ListPrefix returns a list of items with a prefix, normalized. TODO: Add trie for efficient prefix lookup

                              func (*Set) Remove

                              func (s *Set) Remove(key string) error

                                Remove item from this set.

                                func (*Set) Replace

                                func (s *Set) Replace(oldKey string, item Item) error

                                  Replace oldKey with a new item, which might be a new key. Can be used to rename items.

                                  func (*Set) Set

                                  func (s *Set) Set(item Item) error

                                    Set item to this set, even if it already exists.

                                    type StringItem

                                    type StringItem string

                                    func (StringItem) Key

                                    func (item StringItem) Key() string

                                    func (StringItem) Value

                                    func (item StringItem) Value() interface{}

                                    Source Files