tsyncmap

package
v0.0.0-...-c009e49 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package tsyncmap : a timeout based syncmap

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map struct {
	Name       string
	Data       sync.Map
	Timeout    int64
	CheckFreq  int64
	ExpireTime sync.Map
	Verbose    bool
}

Map is the base structure for tsyncmap.

func NewMap

func NewMap(name string, timeout time.Duration, checkfreq time.Duration, verbose bool) *Map

NewMap is a construct function to create tsyncmap.

func (*Map) Delete

func (tmap *Map) Delete(key interface{})

func (*Map) GetRemainTime

func (tmap *Map) GetRemainTime(key interface{}) (time.Duration, error)

func (*Map) Load

func (tmap *Map) Load(key interface{}) (value interface{}, ok bool)

Load returns the value from tsyncmap

func (*Map) LoadRestApi

func (tmap *Map) LoadRestApi(w http.ResponseWriter, r *http.Request)

func (*Map) Run

func (tmap *Map) Run()

Run is a coroutine to help tsyncmap manage the expire data.

func (*Map) ShowData

func (tmap *Map) ShowData()

func (*Map) ShowExpireTime

func (tmap *Map) ShowExpireTime()

func (*Map) Store

func (tmap *Map) Store(key interface{}, value interface{}, currentTime time.Time)

Store is used save the key,value pairs in tsyncmap

func (*Map) UpdateTime

func (tmap *Map) UpdateTime(key interface{}, currentTime time.Time)

UpdateTime is used update specific key's expiretime.

Jump to

Keyboard shortcuts

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