timeoutmap

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Create a map that will timeout entries and call a callback when an object in the map has expired

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Noop

func Noop(obj interface{})

Types

type Node

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

type TimeoutMap

type TimeoutMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(synchronousExpire bool, quit <-chan struct{}) *TimeoutMap

func (*TimeoutMap) Add

func (m *TimeoutMap) Add(key string, obj interface{}, ttl time.Duration, timeoutFunc func(obj interface{}))

func (*TimeoutMap) Checkin

func (m *TimeoutMap) Checkin(key string) bool

func (*TimeoutMap) Delete

func (m *TimeoutMap) Delete(key string)

func (*TimeoutMap) Get

func (m *TimeoutMap) Get(key string) (interface{}, bool)

func (*TimeoutMap) Keys

func (m *TimeoutMap) Keys() []string

func (*TimeoutMap) Start

func (m *TimeoutMap) Start(period time.Duration)

We could create a goroutine for each element in the map and fire timers off of that but it seems a bit excessive instead just clean up the map periodically

func (*TimeoutMap) Stop

func (m *TimeoutMap) Stop()

Jump to

Keyboard shortcuts

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