limitedcache

package
v0.0.0-...-7e31768 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GetOp cache item operation.
	GetOp = OpType(iota)
	// SetOp cache item operation.
	SetOp
	// DeleteOp cache item operation.
	DeleteOp
)

Variables

View Source
var (
	PluginConfig = &limitedcacheConfig{
		done: make(chan struct{}),
	}
)

Config ...

Functions

This section is empty.

Types

type Cache

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

Cache is an implementation of httpcache.Cache with persistent storage.

func New

func New(basePath string, limit int) *Cache

New returns a new Cache that will store files in basePath

func NewWithDiskv

func NewWithDiskv(d *diskv.Diskv, limit int) *Cache

NewWithDiskv returns a new Cache using the provided Diskv as underlying storage.

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes the response with key from the cache.

func (*Cache) Events

func (c *Cache) Events() <-chan CacheOp

Events returns channel with cache operations messages.

func (*Cache) Get

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

Get returns the response corresponding to key if present.

func (*Cache) LoadKeysFromDisk

func (c *Cache) LoadKeysFromDisk(basePath string)

LoadKeysFromDisk - loads cache keys to memory to keep limited cache

func (*Cache) Lost

func (c *Cache) Lost() int

Lost returns number of lost messages - not sent to channel.

func (*Cache) ResetLost

func (c *Cache) ResetLost() int

ResetLost sets lost counter to 0.

func (*Cache) Set

func (c *Cache) Set(key string, resp []byte)

Set saves a response to the cache as key.

type CacheOp

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

CacheOp - operations on cache with key and cache file name.

func (*CacheOp) File

func (em *CacheOp) File() string

File returns cache operation filename on disk.

func (*CacheOp) Key

func (em *CacheOp) Key() string

Key returns cache operation key.

func (*CacheOp) Operation

func (em *CacheOp) Operation() string

Operation returns name of cache operation.

func (*CacheOp) OperationID

func (em *CacheOp) OperationID() OpType

OperationID returns type of cache operation.

func (*CacheOp) Status

func (em *CacheOp) Status() error

Status returns cache operation error.

type OpType

type OpType uint8

OpType is cache operation type enum.

Jump to

Keyboard shortcuts

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