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: 3

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