Documentation ¶
Overview ¶
Package ttlmap is a map with entries that expire after a specified interval
Index ¶
- type TTLMap
- func (t *TTLMap) Clear()
- func (t *TTLMap) Get(key string) (interface{}, bool)
- func (t *TTLMap) Len() int
- func (t *TTLMap) Put(ctx context.Context, key string, val interface{})
- func (t *TTLMap) PutWithTTL(ctx context.Context, key string, val interface{}, ttl time.Duration)
- func (t *TTLMap) TestAndPut(ctx context.Context, key string, val interface{}) bool
- func (t *TTLMap) TestAndPutWithTTL(ctx context.Context, key string, val interface{}, ttl time.Duration) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TTLMap ¶
TTLMap is obscure context
func (*TTLMap) Clear ¶
func (t *TTLMap) Clear()
Clear cancels any pending operations and clears the content of the map
func (*TTLMap) Get ¶
Get returns a value from the map with a specified key or nil if one not present.
func (*TTLMap) Put ¶
Put inserts a new value with a specified key into the map or replaces an existing one. It uses the default TTL specified during the initialization.
func (*TTLMap) PutWithTTL ¶
PutWithTTL inserts a new value with a specified key and TTL into the map or replaces an existing one.
func (*TTLMap) TestAndPut ¶
TestAndPut inserts a new value with a specified key into the map only if none exists. Otherwise, it does nothing and returns `false`. It uses the default TTL specified during the initialization.