cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: CC0-1.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finite

type Finite struct {
	C <-chan interface{} // Objects can be pulled from the cache via this channel. This channel will be closed when the cache is closed. Note that a cache is unordered: the order in which objects are recovered from the cache via this channel has no relation to the order in which they were added to the cache.
	// contains filtered or unexported fields
}

Finite is a cache of fixed size used for storing unordered data. It will flush automatically when full, and on close.

func NewFinite

func NewFinite(maxSize int, flush FlushFunc) *Finite

NewFinite returns a new finite cache of maximum size maxSize using the given flush function.

func (*Finite) Add

func (c *Finite) Add(x interface{}) error

Add places x onto the cache.

func (*Finite) Close

func (c *Finite) Close() error

Close closes the cache. Any cached data will be flushed.

func (*Finite) Err

func (c *Finite) Err() (err error)

Err returns the any error.

func (*Finite) Flush

func (c *Finite) Flush()

Flush flushes the cache.

func (*Finite) FlushAllButN

func (c *Finite) FlushAllButN(N int)

FlushAllButN flushes all but N elements from the cache.

func (*Finite) Len

func (c *Finite) Len() (n int)

Len returns the number of objects currently in the cache.

func (*Finite) SetError

func (c *Finite) SetError(err error)

SetError places the cache in an error state.

type FlushFunc

type FlushFunc func([]interface{}) error

FlushFunc defines a function to be used to flush the cache.

Jump to

Keyboard shortcuts

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