tree

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: AGPL-3.0, GPL-2.0, LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpireAtSecs

type ExpireAtSecs int64

type Tree

type Tree struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Tree is a a thread-safe data structure for tracking expirable items. It automatically expires old entries and keys. It does not garbage collect. Items are only expired when interacting with the data structure.

func NewTree

func NewTree(expireAfterSecs int64) *Tree

func (*Tree) Count

func (n *Tree) Count(entryKey string) int

Count will return the number of entries at `entryKey`. It has the side effect of cleaning up stale entries and entry keys.

func (*Tree) KeyMatch added in v0.5.1

func (n *Tree) KeyMatch(keyPattern string) []string

KeyMatch crawls the subtree to return keys starting with the `keyPattern` string.

func (*Tree) Keys

func (n *Tree) Keys() ([]string, int)

Keys returns a list of all valid keys in the tree, and a sum of every key's valid entries. It is expensive because it will result in the entire tree being counted and expired where necessary.

func (*Tree) Put

func (n *Tree) Put(entryKey string)

Jump to

Keyboard shortcuts

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