Documentation ¶
Overview ¶
Package ttlmap provides a map-like interface with string keys and expirable items. Keys are currently limited to strings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrExists = errors.New("item already exists") ErrDrained = errors.New("map was drained") )
Errors returned by Set and SetNX operations.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Item represents an expirable item associated with a given value.
func NewItemWithTTL ¶
NewItemWithTTL creates an item with the specified value and expiring after the specified duration.
func (*Item) Expiration ¶
Expiration returns the item's expiration time.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is the equivalent of a map[string]interface{} but with expirable Items.
func (*Map) Delete ¶
Delete deletes the item with the specified key in the map. If an item is found, it is returned.
func (*Map) Drain ¶
func (m *Map) Drain()
Drain evicts all remaining elements from the map and terminates the usage of this map.
func (*Map) Draining ¶
func (m *Map) Draining() <-chan struct{}
Draining returns the channel that is closed when the map starts draining.