ttlmap

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TTLMap

type TTLMap struct {
	// contains filtered or unexported fields
}

TTLMap is a map that evicts entries after the configured ttl has elapsed.

func New

func New(sweepIntervalSeconds int64, maxAgeSeconds int64) *TTLMap

New creates a TTLMap. The sweepIntervalSeconds arg indicates how often entries are checked for expiration. The maxAgeSeconds arg indicates how long entries can persist before getting evicted. Call Start() on the returned TTLMap to begin periodic sweeps which check for expiration and evict entries as needed.

func (*TTLMap) Get

func (m *TTLMap) Get(k string) interface{}

Get returns the object in the underlying map at the given key. If there is no value at that key, Get returns nil.

func (*TTLMap) Put

func (m *TTLMap) Put(k string, v interface{})

Put adds the passed-in key and value to the underlying map. The current time is attached to the entry for periodic expiration checking and eviction when necessary.

func (*TTLMap) Start

func (m *TTLMap) Start()

Start starts periodic sweeps for expired entries in the underlying map.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL