cache

package
v0.0.0-...-ecdd255 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cache implements a simplistic persistent cache based on the filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTree

func GetTree(repo *git.Repository, id *git.Oid) (*gitiles.Tree, error)

GetTree loads the Tree from an on-disk Git repository.

Types

type CAS

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

CAS is a content addressable storage. It is intended to be used with git SHA1 data. It stores blobs as uncompressed files without git headers. This means that we can wire up files from the CAS directly with a FUSE file system.

func NewCAS

func NewCAS(dir string) (*CAS, error)

NewCAS creates a new CAS object.

func (*CAS) Open

func (c *CAS) Open(id git.Oid) (*os.File, bool)

Open returns a file corresponding to the blob, opened for reading.

func (*CAS) Write

func (c *CAS) Write(id git.Oid, data []byte) error

Write writes the given data under the given ID atomically.

type Cache

type Cache struct {
	Git  *gitCache
	Tree *TreeCache
	Blob *CAS
	// contains filtered or unexported fields
}

Cache combines a blob, tree and git repo cache.

func NewCache

func NewCache(d string, opts Options) (*Cache, error)

NewCache sets up a Cache instance according to the given options.

func (*Cache) Root

func (c *Cache) Root() string

Root returns the directory holding the cache storage.

type LazyRepo

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

LazyRepo represents a git repository that might be fetched on demand.

func NewLazyRepo

func NewLazyRepo(url string, cache *Cache) *LazyRepo

NewLazyRepo creates a new repository. If the repository is never to be cloned, url should be set to empty string.

func (*LazyRepo) Clone

func (r *LazyRepo) Clone()

Clone schedules the repository to be cloned. This method is safe for concurrent use from multiple goroutines.

func (*LazyRepo) Repository

func (r *LazyRepo) Repository() *git.Repository

Repository returns a git.Repository for this repo, or nil if it wasn't loaded. This method is safe for concurrent use from multiple goroutines. The return value must not be Free'd since it is persisted inside LazyRepo.

type Options

type Options struct {
	// FetchFrequency controls how often we run git fetch on the
	// locally cached git repositories.
	FetchFrequency time.Duration
}

Options defines configurable options for the different caches.

type TreeCache

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

A TreeCache caches recursively expanded trees by their git commit and tree IDs.

func NewTreeCache

func NewTreeCache(d string) (*TreeCache, error)

NewTreeCache constructs a new TreeCache.

func (*TreeCache) Add

func (c *TreeCache) Add(id *git.Oid, tree *gitiles.Tree) error

Add adds a Tree to the cache

func (*TreeCache) Get

func (c *TreeCache) Get(id *git.Oid) (*gitiles.Tree, error)

Get returns a tree, if available.

Jump to

Keyboard shortcuts

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