lru

package
v1.0.46 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewLRU

func NewLRU(ctx libkb.LRUContext, sz int, version int, exampleObj interface{}) *Cache

func (*Cache) ClearMemory

func (c *Cache) ClearMemory()

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, lctx libkb.LRUContext, k libkb.LRUKeyer) (interface{}, error)

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, lctx libkb.LRUContext, k libkb.LRUKeyer, v interface{}) error

type DiskLRU

type DiskLRU struct {
	sync.Mutex
	// contains filtered or unexported fields
}

DiskLRU maintains a cache of files on the disk in a LRU manner.

func NewDiskLRU

func NewDiskLRU(name string, version int, maxSize int) *DiskLRU

func (*DiskLRU) ClearMemory

func (d *DiskLRU) ClearMemory(ctx context.Context, lctx libkb.LRUContext)

func (*DiskLRU) Flush

func (d *DiskLRU) Flush(ctx context.Context, lctx libkb.LRUContext) error

func (*DiskLRU) Get

func (d *DiskLRU) Get(ctx context.Context, lctx libkb.LRUContext, key string) (found bool, res DiskLRUEntry, err error)

func (*DiskLRU) Put

func (d *DiskLRU) Put(ctx context.Context, lctx libkb.LRUContext, key string, value interface{}) (evicted *DiskLRUEntry, err error)

func (*DiskLRU) Remove

func (d *DiskLRU) Remove(ctx context.Context, lctx libkb.LRUContext, key string) (err error)

func (*DiskLRU) Size

func (d *DiskLRU) Size(ctx context.Context, lctx libkb.LRUContext) (int, error)

type DiskLRUEntry

type DiskLRUEntry struct {
	Key          string
	Value        interface{}
	Ctime        time.Time
	LastAccessed time.Time
}

Jump to

Keyboard shortcuts

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