go-git.v4: gopkg.in/src-d/go-git.v4/plumbing/cache Index | Files

package cache

import "gopkg.in/src-d/go-git.v4/plumbing/cache"

Index

Package Files

buffer_lru.go common.go object_lru.go

type Buffer Uses

type Buffer interface {
    // Put puts a buffer into the cache. If the buffer is already in the cache,
    // it will be marked as used. Otherwise, it will be inserted. Buffer might
    // be evicted to make room for the new one.
    Put(key int64, slice []byte)
    // Get returns a buffer by its key. It marks the buffer as used. If the
    // buffer is not in the cache, (nil, false) will be returned.
    Get(key int64) ([]byte, bool)
    // Clear clears every object from the cache.
    Clear()
}

Buffer is an interface to a buffer cache.

type BufferLRU Uses

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

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

func NewBufferLRU Uses

func NewBufferLRU(maxSize FileSize) *BufferLRU

NewBufferLRU creates a new BufferLRU with the given maximum size. The maximum size will never be exceeded.

func NewBufferLRUDefault Uses

func NewBufferLRUDefault() *BufferLRU

NewBufferLRUDefault creates a new BufferLRU with the default cache size.

func (*BufferLRU) Clear Uses

func (c *BufferLRU) Clear()

Clear the content of this buffer cache.

func (*BufferLRU) Get Uses

func (c *BufferLRU) Get(key int64) ([]byte, bool)

Get returns a buffer by its key. It marks the buffer as used. If the buffer is not in the cache, (nil, false) will be returned.

func (*BufferLRU) Put Uses

func (c *BufferLRU) Put(key int64, slice []byte)

Put puts a buffer into the cache. If the buffer is already in the cache, it will be marked as used. Otherwise, it will be inserted. A buffers might be evicted to make room for the new one.

type FileSize Uses

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

type Object Uses

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 Uses

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 Uses

func NewObjectLRU(maxSize FileSize) *ObjectLRU

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

func NewObjectLRUDefault Uses

func NewObjectLRUDefault() *ObjectLRU

NewObjectLRUDefault creates a new ObjectLRU with the default cache size.

func (*ObjectLRU) Clear Uses

func (c *ObjectLRU) Clear()

Clear the content of this object cache.

func (*ObjectLRU) Get Uses

func (c *ObjectLRU) Get(k plumbing.Hash) (plumbing.EncodedObject, bool)

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 Uses

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.

Package cache imports 3 packages (graph) and is imported by 38 packages. Updated 2019-08-04. Refresh now. Tools for package owners.