ttlmap

package
Version: v0.0.0-...-c360844 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2016 License: Apache-2.0, MIT Imports: 4 Imported by: 0

README

Build Status Build Status

TtlMap

Redis-like Map with expiry times and maximum capacity


import "github.com/mailgun/ttlmap"

mh, _ := ttlmap.NewMap(20)
mh.Set("key1", "value", 20)
valI, exists := mh.Get("key2")
if exists {
   val := valI.(string)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(key string, el interface{})

type TtlMap

type TtlMap struct {
	TimeProvider timetools.TimeProvider
	// contains filtered or unexported fields
}

func NewMap

func NewMap(capacity int, opts ...TtlMapOption) (*TtlMap, error)

func NewMapWithProvider

func NewMapWithProvider(capacity int, timeProvider timetools.TimeProvider) (*TtlMap, error)

func (*TtlMap) Get

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

func (*TtlMap) GetInt

func (m *TtlMap) GetInt(key string) (int, bool, error)

func (*TtlMap) Increment

func (m *TtlMap) Increment(key string, value int, ttlSeconds int) (int, error)

func (*TtlMap) Len

func (m *TtlMap) Len() int

func (*TtlMap) Set

func (m *TtlMap) Set(key string, value interface{}, ttlSeconds int) error

type TtlMapOption

type TtlMapOption func(m *TtlMap) error

func CallOnExpire

func CallOnExpire(cb Callback) TtlMapOption

CallOnExpire will call this callback on expiration of elements

func Clock

Clock sets the time provider clock, handy for testing

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL