timestore

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Greater

func Greater(oldTime, newTime time.Time) bool

func Less

func Less(oldTime, newTime time.Time) bool

Types

type TimeStore

type TimeStore struct {
	// Underlying data store
	sync.Map
	// contains filtered or unexported fields
}

TimeStore{} stores arbitrary time.Time. It allows for safe pushes and pops based on any arbitrary keys.

func NewTimeStore

func NewTimeStore(eval func(oldTime, newTime time.Time) bool) *TimeStore

NewDurationStore() returns a time store which will evaluate which value to keep, when multiple are pushed to the same key, based on the eval() function.

func (*TimeStore) Peek

func (ts *TimeStore) Peek(key string) time.Time

Peek() will return the time stored by the key and *not* delete the store. If no time was stored for that key, then 0 will be returned.

func (*TimeStore) Pop

func (ts *TimeStore) Pop(key string) time.Time

Pop() will return the time stored by the key and delete the store. If no time was stored for that key, then 0 will be returned.

func (*TimeStore) Push

func (ts *TimeStore) Push(key string, newTime time.Time)

Push() will store a time for the key. If multiple values are pushed onto the same key before the key is popped, then the one that returns true from TimeStore.eval() is kept.

Jump to

Keyboard shortcuts

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