lru

package
v0.0.0-...-a8b6a46 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: BSD-3-Clause, BSD-3-Clause Imports: 12 Imported by: 0

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