timemap

package module
v0.0.0-...-3d1ef27 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: MIT Imports: 3 Imported by: 0

README

golang-timemap

A thread-safe time-based key-value store for Go.

Documentation

Full docs are available on Godoc

Example

func main() {
	l := timemap.New()
	l.Set("name", "Rustacean", time.Now())
	time.Sleep(10 * time.Millisecond)
	l.Set("name", "Gopher", time.Now())
	v, _ := l.Get("name", time.Now())
	fmt.Println(v) # Expect "Gopher" :-)
}

Documentation

Overview

Package timemap provides a thread-safe time-based key-value store for Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

Map is a thread-safe fixed size time-based map.

func New

func New() *Map

New creates a time-based map.

func (*Map) Contains

func (t *Map) Contains(key string) bool

Contains checks if a key exists in the map.

func (*Map) Get

func (t *Map) Get(key string, timestamp time.Time) (value interface{}, ok bool)

Get looks up a key's value based on a timestamp.

func (*Map) Keys

func (t *Map) Keys() []string

Keys returns a slice of the keys from the map.

func (*Map) Remove

func (t *Map) Remove(key string) bool

Remove removes the provided key from the map.

func (*Map) Set

func (t *Map) Set(key string, value interface{}, timestamp time.Time) bool

Set sets a new value and timestamp to a specific key.

Jump to

Keyboard shortcuts

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