utils

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEvictedBufferSize = 16

Variables

This section is empty.

Functions

func CombineData

func CombineData(ttl time.Duration, val []byte) []byte

func CopyBytes

func CopyBytes(data []byte) []byte

func CutStringSlice

func CutStringSlice(keys []string, prefix, limit string) []string

func GetTimeNow added in v1.0.3

func GetTimeNow() time.Time

func SplitData

func SplitData(val []byte) (bool, int, []byte)

Types

type EvictCallback

type EvictCallback func(key interface{}, value interface{})

type LRU

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

func NewLRU

func NewLRU(size int, onEvict EvictCallback) *LRU

func (*LRU) Add

func (c *LRU) Add(key, value interface{}) (evicted bool)

func (*LRU) Clear

func (c *LRU) Clear()

func (*LRU) Contains

func (c *LRU) Contains(key interface{}) (ok bool)

func (*LRU) Get

func (c *LRU) Get(key interface{}) (value interface{}, ok bool)

func (*LRU) GetOldest

func (c *LRU) GetOldest() (key, value interface{}, ok bool)

func (*LRU) Keys

func (c *LRU) Keys() []interface{}

func (*LRU) Len

func (c *LRU) Len() int

func (*LRU) Peek

func (c *LRU) Peek(key interface{}) (value interface{}, ok bool)

func (*LRU) Remove

func (c *LRU) Remove(key interface{}) (present bool)

func (*LRU) RemoveOldest

func (c *LRU) RemoveOldest() (key, value interface{}, ok bool)

func (*LRU) Resize

func (c *LRU) Resize(size int) (evicted int)

Jump to

Keyboard shortcuts

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