cache

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cache provides an interface for interfacing with the Glide local cache

Glide has a local cache of metadata and repositories similar to the GOPATH. To store the cache Glide creates a .glide directory with a cache subdirectory. This is usually in the users home directory unless there is no accessible home directory in which case the .glide directory is in the root of the repository.

To get the cache location use the `cache.Location()` function. This will return the proper base location in your environment.

Within the cache directory there are two subdirectories. They are the src and info directories. The src directory contains version control checkouts of the packages. The info direcory contains metadata. The metadata maps to the RepoInfo struct. Both stores are happed to keys.

Using the `cache.Key()` function you can get a key for a repo. Pass in a location such as `https://github.com/foo/bar` or `git@example.com:foo.git` and a key will be returned that can be used for caching operations.

Note, the caching is based on repo rather than package. This is important for a couple reasons.

  1. Forks or package replacements are supported in Glide. Where a different repo maps to a package.
  2. Permissions enable different access. For example `https://example.com/foo.git` and `git@example.com:foo.git` may have access to different branches or tags.

Index

Constants

This section is empty.

Variables

View Source
var Enabled = true

Enabled sets if the cache is globally enabled. Defaults to true.

View Source
var ErrCacheDisabled = errors.New("Cache disabled")

ErrCacheDisabled is returned with the cache is disabled.

Functions

func Key

func Key(repo string) (string, error)

Key generates a cache key based on a url or scp string. The key is file system safe.

func Location

func Location() string

Location returns the location of the cache.

func Lock

func Lock(name string)

Lock locks a particular key name

func MemCurrent

func MemCurrent(name string) string

MemCurrent is used to get the current version in use.

func MemLatest

func MemLatest(name string) string

MemLatest returns the latest, that is most recent, semver release. This may be a blank string if no put value

func MemPut

func MemPut(name, version string)

MemPut put a version into the in memory cache for a name. This will silently ignore non-semver and make sure the latest is stored.

func MemSetCurrent

func MemSetCurrent(name, version string)

MemSetCurrent is used to set the current version in use.

func MemTouch

func MemTouch(name string)

MemTouch notes if a name has been looked at.

func MemTouched

func MemTouched(name string) bool

MemTouched returns true if the cache was touched for a name.

func SaveRepoData

func SaveRepoData(key string, data RepoInfo) error

SaveRepoData stores data about a repo in the Glide cache

func Setup

func Setup()

Setup creates the cache location.

func SetupReset

func SetupReset()

SetupReset resets if setup has been completed. The next time setup is run it will attempt a full setup.

func SystemLock

func SystemLock() error

SystemLock starts a system rather than application lock. This way multiple app instances don't cause race conditions when working in the cache.

func SystemUnlock

func SystemUnlock()

SystemUnlock removes the system wide Glide cache lock.

func Unlock

func Unlock(name string)

Unlock unlocks a particular key name

Types

type RepoInfo

type RepoInfo struct {
	DefaultBranch string `json:"default-branch"`
	LastUpdate    string `json:"last-update"`
}

RepoInfo holds information about a repo.

func RepoData

func RepoData(key string) (*RepoInfo, error)

RepoData retrieves cached information about a repo.

Jump to

Keyboard shortcuts

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