ttlset

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	EntryTTL time.Duration // time after which items are removed
	Clock    clock.Clock   // time reference
}

Config defines the TTLSet configuration

type TTLSet

type TTLSet struct {
	Config
	// contains filtered or unexported fields
}

TTLSet implements a Set that automatically removes expired keys after a predefined expiration time

func New

func New(config *Config) *TTLSet

New instances a TTLSet

func (*TTLSet) Add

func (ts *TTLSet) Add(key interface{}) error

Add adds a new key to the set

func (*TTLSet) Count

func (ts *TTLSet) Count() int

Count returns the number of entries in the set

func (*TTLSet) GC

func (ts *TTLSet) GC()

GC will remove expired entries from the set

func (*TTLSet) Has

func (ts *TTLSet) Has(key interface{}) bool

Has returns whether or not a key is already/still in the set

Jump to

Keyboard shortcuts

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