lru

package
v4.3.2+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanOutOfSyncWithDelay

func CleanOutOfSyncWithDelay(mctx libkb.MetaContext, d *DiskLRU, cacheDir string, delay time.Duration)

CleanOutOfSyncWithDelay runs the LRU clean function after the `delay` duration. If the service crashes it's possible that temporarily files get stranded on disk before they can get recorded in the LRU. Callers can run this in the background to prevent leaking space. We delay to keep off the critical path to start up.

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) OnDbNuke

func (c *Cache) OnDbNuke(mctx libkb.MetaContext) error

func (*Cache) OnLogout

func (c *Cache) OnLogout(mctx libkb.MetaContext) error

func (*Cache) Put

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

type DiskLRU added in v1.0.46

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 added in v1.0.46

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

func (*DiskLRU) CleanOutOfSync

func (d *DiskLRU) CleanOutOfSync(mctx libkb.MetaContext, cacheDir string) error

func (*DiskLRU) ClearMemory added in v1.0.46

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

func (*DiskLRU) Flush added in v1.0.46

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

func (*DiskLRU) Get added in v1.0.46

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

func (*DiskLRU) MaxSize

func (d *DiskLRU) MaxSize() int

func (*DiskLRU) Put added in v1.0.46

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

func (*DiskLRU) Remove added in v1.0.46

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

func (*DiskLRU) Size added in v1.0.46

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

type DiskLRUEntry added in v1.0.46

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