cache

package
v0.0.0-...-b178995 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cache implements a disk-backed LRU cache for "big" binary blob

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache holds a cache instance, backed by a single file and an in-memory list

func New

func New(dir, name string, maxSize int64) (*Cache, error)

New initializes a new LRU cache

func (*Cache) Add

func (c *Cache) Add(key string, value []byte) error

Add adds/updates the given key/value pair

func (*Cache) Close

func (c *Cache) Close() error

Close closes the cache

func (*Cache) Get

func (c *Cache) Get(key string) ([]byte, bool, error)

Get returns the given key if present

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items stored

func (*Cache) Size

func (c *Cache) Size() int64

Size returns the disk usage of the cache file

func (*Cache) Stat

func (c *Cache) Stat(key string) (bool, error)

Stat returns true if the key is stored

Jump to

Keyboard shortcuts

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