reader

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvictCallback

type EvictCallback func(key int, value interface{})

EvictCallback is used to get a callback when a cache entry is evicted

type LRU

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

LRU implements a thread safe fixed size LRU cache

func NewLRU

func NewLRU(size int, onEvict EvictCallback) (*LRU, error)

NewLRU constructs an LRU of the given size

func (*LRU) Add

func (c *LRU) Add(key int, value interface{}) (evicted bool)

Add adds a value to the cache. Returns true if an eviction occurred.

func (*LRU) Contains

func (c *LRU) Contains(key int) (ok bool)

Contains checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.

func (*LRU) Get

func (c *LRU) Get(key int) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (*LRU) GetOldest

func (c *LRU) GetOldest() (key int, value interface{}, ok bool)

GetOldest returns the oldest entry

func (*LRU) Keys

func (c *LRU) Keys() []int

Keys returns a slice of the keys in the cache, from oldest to newest.

func (*LRU) Len

func (c *LRU) Len() int

Len returns the number of items in the cache.

func (*LRU) Peek

func (c *LRU) Peek(key int) (value interface{}, ok bool)

Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.

func (*LRU) Purge

func (c *LRU) Purge()

Purge is used to completely clear the cache.

func (*LRU) Remove

func (c *LRU) Remove(key int) (present bool)

Remove removes the provided key from the cache, returning if the key was contained.

func (*LRU) RemoveOldest

func (c *LRU) RemoveOldest() (key int, value interface{}, ok bool)

RemoveOldest removes the oldest item from the cache.

type PagedReader

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

func NewPagedReader

func NewPagedReader(reader io.ReaderAt, pagesize int64, cache_size int) (*PagedReader, error)

func (*PagedReader) ReadAt

func (self *PagedReader) ReadAt(buf []byte, offset int64) (int, error)

Jump to

Keyboard shortcuts

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