timap

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 2 Imported by: 1

README

Timap

Build Status Report Card GoCover

Timap is a wrapper over sync.Map that allows to set life time for each key-value pair.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Timap

type Timap interface {
	Load(key interface{}) (value interface{}, ok bool)
	Store(key, value interface{}, lifeTime ...time.Duration)
	Delete(key interface{})
	Range(f func(key, value interface{}) bool)
}

Timap represents "time map", it is a wrapper over sync.Map that allows to store key-value pairs for certain period of time. Default duration can be defined for all key-value pairs in the constructor func, but it is also possible to define custom life time for each pair separately. Watcher will create a goroutine for every temporrary pair. Try not to use it with huge maps.

func New

func New(lifeTime time.Duration) Timap

New is a Timap constructor func. If lifeTime == 0 key-value pairs will not have any time limits (by default), values still can be deleted by calling Delete().

Jump to

Keyboard shortcuts

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