disk

package
v0.0.0-...-39d5f47 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(dir string, maxSizeBytes int64, readOnly bool) cache.Cache

New returns a new instance of a filesystem-based cache rooted at `dir`, with a maximum size of `maxSizeBytes` bytes.

Types

type EvictCallback

type EvictCallback func(key Key, value SizedItem)

EvictCallback is the type of callbacks that are invoked when items are evicted.

type Key

type Key interface{}

type SizedItem

type SizedItem interface {
	Size() int64
}

type SizedLRU

type SizedLRU interface {
	Add(key Key, value SizedItem) (ok bool)
	Get(key Key) (value SizedItem, ok bool)
	Remove(key Key)
	Len() int
	CurrentSize() int64
	MaxSize() int64
}

SizedLRU is an LRU cache that will keep its total size below maxSize by evicting items. SizedLRU is not thread-safe.

func NewSizedLRU

func NewSizedLRU(maxSize int64, onEvict EvictCallback) SizedLRU

NewSizedLRU returns a new sizedLRU cache

Jump to

Keyboard shortcuts

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