cache

package
v4.0.0-rc14+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSize

type FileSize int64
const (
	Byte FileSize = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
)

type Object

type Object interface {
	// Put puts the given object into the cache. Whether this object will
	// actually be put into the cache or not is implementation specific.
	Put(o plumbing.EncodedObject)
	// Get gets an object from the cache given its hash. The second return value
	// is true if the object was returned, and false otherwise.
	Get(k plumbing.Hash) (plumbing.EncodedObject, bool)
	// Clear clears every object from the cache.
	Clear()
}

Object is an interface to a object cache.

type ObjectLRU

type ObjectLRU struct {
	MaxSize FileSize
	// contains filtered or unexported fields
}

ObjectLRU implements an object cache with an LRU eviction policy and a maximum size (measured in object size).

func NewObjectLRU

func NewObjectLRU(maxSize FileSize) *ObjectLRU

NewObjectLRU creates a new ObjectLRU with the given maximum size. The maximum size will never be exceeded.

func (*ObjectLRU) Clear

func (c *ObjectLRU) Clear()

Clear the content of this object cache.

func (*ObjectLRU) Get

Get returns an object by its hash. It marks the object as used. If the object is not in the cache, (nil, false) will be returned.

func (*ObjectLRU) Put

func (c *ObjectLRU) Put(obj plumbing.EncodedObject)

Put puts an object into the cache. If the object is already in the cache, it will be marked as used. Otherwise, it will be inserted. A single object might be evicted to make room for the new object.

Jump to

Keyboard shortcuts

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