tlru

package
v0.10.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

tlru (time aware least recently lastUsed) has the same overwriting strategy as LRU, but adds a lifetime to objects on creation. Objects whose lifetime is outdated, are considered dead and can be removed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheItem

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

func NewCacheItem

func NewCacheItem(content interface{}, lifetime time.Duration) *CacheItem

func (*CacheItem) Object

func (i *CacheItem) Object() interface{}

func (*CacheItem) Set

func (i *CacheItem) Set(v interface{})

type CacheList

type CacheList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCacheList

func NewCacheList(size uint, lifetime time.Duration) *CacheList

func (*CacheList) Cap added in v0.8.4

func (list *CacheList) Cap() uint

func (*CacheList) ClearHard added in v0.8.4

func (list *CacheList) ClearHard()

func (*CacheList) ClearSoft added in v0.8.4

func (list *CacheList) ClearSoft()

func (*CacheList) ClearTableNils added in v0.8.4

func (list *CacheList) ClearTableNils()

func (*CacheList) ClearTables added in v0.8.4

func (list *CacheList) ClearTables()

func (*CacheList) CreateCacheableItem

func (list *CacheList) CreateCacheableItem(content interface{}) interfaces.CacheableItem

func (*CacheList) Delete

func (list *CacheList) Delete(id Snowflake)

func (*CacheList) Efficiency

func (list *CacheList) Efficiency() float64

Efficiency ...

func (*CacheList) First

func (list *CacheList) First() (item *CacheItem, key Snowflake)

func (*CacheList) Get

func (list *CacheList) Get(id Snowflake) (ret interfaces.CacheableItem, exists bool)

get an item from the list.

func (*CacheList) RefreshAfterDiscordUpdate

func (list *CacheList) RefreshAfterDiscordUpdate(itemI interfaces.CacheableItem)

func (*CacheList) Set

func (list *CacheList) Set(id Snowflake, newItemI interfaces.CacheableItem)

set adds a new item to the list or returns false if the item already exists

func (*CacheList) Size added in v0.8.4

func (list *CacheList) Size() uint

type Snowflake

type Snowflake = snowflake.Snowflake

Jump to

Keyboard shortcuts

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