tlru

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: BSD-3-Clause Imports: 4 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) 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

type Snowflake

type Snowflake = snowflake.Snowflake

Jump to

Keyboard shortcuts

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