ttlmap

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TTLMap

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

TTLMap is a simple kv cache, based on https://stackoverflow.com/a/25487392 The ttl of an item will be reset whenever it is read or written.

func New

func New(ln int, maxTTL int) (m *TTLMap)

New creates a new ttl cache, preallocating space for ln items and the given maxttl

func (*TTLMap) Get

func (m *TTLMap) Get(k string) (v string)

Get retrieves an item from the cache, resetting the ttl

func (*TTLMap) Len

func (m *TTLMap) Len() int

Len returns the current number of items in the cache

func (*TTLMap) Put

func (m *TTLMap) Put(k, v string)

Put sets or overwrites an item, resetting the ttl

Jump to

Keyboard shortcuts

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