lru

package
v0.0.0-...-9648343 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SDLRU

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

SDLRU is an LRU for strings with a maximum age

func NewStringDecayLRU

func NewStringDecayLRU(capacity int) *SDLRU

NewStringDecayLRU creates a new string LRU with a maximum capacity. TODO: decay mechanism?

func (*SDLRU) Add

func (s *SDLRU) Add(val string, ts int64) bool

Add adds the given value and returns true if the value was in the cache.

func (*SDLRU) AddUnless

func (s *SDLRU) AddUnless(val string, ts, delta int64) bool

AddUnless adds/refreshes the value and returns true if the value is not in the cache or if it is older than delta.

func (*SDLRU) Check

func (s *SDLRU) Check(val string, ts, delta int64) bool

Check checks if the value is in the cache and not older than ts by delta seconds.

func (*SDLRU) Delete

func (s *SDLRU) Delete(key string) bool

Delete removes a key from the LRU and returns if the key was in the cache.

func (*SDLRU) Iter

func (s *SDLRU) Iter(f func(string, int64) bool)

Iter iterates over all values in the cache.

func (*SDLRU) String

func (s *SDLRU) String() string

String returns a string representation of the LRU entries for debugging.

type SLRU

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

SLRU is an LRU for strings

func NewStringLRU

func NewStringLRU(capacity int) *SLRU

NewStringLRU creates a new string LRU with a maximum capacity.

func (*SLRU) Delete

func (s *SLRU) Delete(key string) (interface{}, bool)

Delete removes a key from the LRU and returns if the key was in the cache.

func (*SLRU) Get

func (s *SLRU) Get(key string) (interface{}, bool)

Get returns the value associated with the key, if it is in the cache.

func (*SLRU) Iter

func (s *SLRU) Iter(f func(key string, v interface{}) bool)

Iter iterates over the list values in most-recent-to-last order,

func (*SLRU) Set

func (s *SLRU) Set(key string, v interface{}) bool

Set adds the given value and returns true if the value was already in the cache.

func (*SLRU) Size

func (s *SLRU) Size() int

Size returns the elements in the LRU.

func (*SLRU) String

func (s *SLRU) String() string

String returns a string representation of the LRU entries for debugging.

func (*SLRU) TailRemove

func (s *SLRU) TailRemove(f func(key string, v interface{}) bool)

Jump to

Keyboard shortcuts

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