cache

package
v0.0.0-...-3b6d39f Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Metadata *MetadataCache
	Content  *ContentCache
}

Cache implements the unified cache.

func NewCache

func NewCache(root string, syscalls real.Syscalls) (*Cache, error)

NewCache instantantiates a new cache.

func (*Cache) Close

func (c *Cache) Close() error

Close closes the cache in a controller manner.

type CachedRow

type CachedRow struct {
	Inode       uint64
	TypeName    string
	FileInfo    *os.FileInfo
	DidReadDir  bool
	DirEntries  map[string]OneDirEntry
	ContentHash *Key
	Target      *string
}

CachedRow contains all the data for an inode as known by the cache.

type ContentCache

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

ContentCache implements the content cache.

func NewContentCache

func NewContentCache(root string, syscalls real.Syscalls) *ContentCache

NewContentCache instantiates a new content cache.

func (*ContentCache) GetFileForContents

func (cache *ContentCache) GetFileForContents(key Key) (string, error)

GetFileForContents returns the path to file containing the contents for the key.

func (*ContentCache) HasKey

func (cache *ContentCache) HasKey(key Key) (bool, error)

HasKey checks if the given key is in the cache.

func (*ContentCache) PutContents

func (cache *ContentCache) PutContents(path string) (Key, error)

PutContents stores the given file in the cache and returns the key.

func (*ContentCache) Root

func (cache *ContentCache) Root() string

Root returns the path to the root of the cache.

type Key

type Key string

Key represents a key in the cache. Keys are file digests.

type MetadataCache

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

MetadataCache is a persistent database of the file system metadata for all known entries.

func NewMetadataCache

func NewMetadataCache(path string) (*MetadataCache, error)

NewMetadataCache opens a new connection to the given database.

func (*MetadataCache) Close

func (cache *MetadataCache) Close() error

Close terminates the connection to the database.

func (*MetadataCache) GetDirEntries

func (cache *MetadataCache) GetDirEntries(inode uint64, outEntries *map[string]OneDirEntry) error

GetDirEntries reads the directory entries stored in an inode.

func (*MetadataCache) GetFullEntry

func (cache *MetadataCache) GetFullEntry(path string) (*CachedRow, error)

GetFullEntry reads the full metadata for a file.

func (*MetadataCache) PutContentHash

func (cache *MetadataCache) PutContentHash(inode uint64, contentHash Key) error

PutContentHash stores a new content hash for an existing inode.

func (*MetadataCache) PutDirEntries

func (cache *MetadataCache) PutDirEntries(inode uint64, path string, entries []os.FileInfo) error

PutDirEntries stores a new set of directory entries for an existing inode.

func (*MetadataCache) PutFileInfo

func (cache *MetadataCache) PutFileInfo(inode uint64, fileInfo os.FileInfo) error

PutFileInfo stores new file details for an existing inode.

func (*MetadataCache) PutNewNoEntry

func (cache *MetadataCache) PutNewNoEntry(path string) (uint64, error)

PutNewNoEntry stores a new whiteout entry for the given path.

func (*MetadataCache) PutNewOrUpdateNoEntry

func (cache *MetadataCache) PutNewOrUpdateNoEntry(path string) error

PutNewOrUpdateNoEntry stores a new whiteout entry or updates an existing one.

func (*MetadataCache) PutNewOrUpdateWithType

func (cache *MetadataCache) PutNewOrUpdateWithType(path string, fileMode os.FileMode) error

PutNewOrUpdateWithType stores a new entry or updates an existing one to match the given type.

func (*MetadataCache) PutNewWithType

func (cache *MetadataCache) PutNewWithType(path string, fileMode os.FileMode) (uint64, error)

PutNewWithType stores a new entry for a path given its file type.

func (*MetadataCache) PutSymlinkTarget

func (cache *MetadataCache) PutSymlinkTarget(inode uint64, target string) error

PutSymlinkTarget stores a new symlink target for an existing inode.

type OneDirEntry

type OneDirEntry struct {
	Valid    bool
	Inode    uint64
	ModeType os.FileMode
}

OneDirEntry represents a single directory entry.

type RetriableRow

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

RetriableRow wraps an sql.Row to be used as a helper for RetryQueryRow.

func (*RetriableRow) Scan

func (row *RetriableRow) Scan(dest ...interface{}) error

Scan wraps sql.DB.Row.Scan to automatically retry on database contention.

type RetriableStmt

type RetriableStmt struct {
	*sql.Stmt
}

RetriableStmt extends an sql.Stmt with functions to retry queries.

func (*RetriableStmt) RetryExec

func (stmt *RetriableStmt) RetryExec(id string, args ...interface{}) (
	sql.Result, error)

RetryExec wraps sql.DB.Exec to automatically retry on database contention.

func (*RetriableStmt) RetryQuery

func (stmt *RetriableStmt) RetryQuery(id string, args ...interface{}) (
	*sql.Rows, error)

RetryQuery wraps sql.DB.Query to automatically retry on database contention.

func (*RetriableStmt) RetryQueryRow

func (stmt *RetriableStmt) RetryQueryRow(id string, args ...interface{}) *RetriableRow

RetryQueryRow wraps sql.DB.QueryRow to automatically retry on database contention.

Jump to

Keyboard shortcuts

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