cache

package
v0.0.0-...-2bbe97e Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DaemonContainerBucket is the name of the bucket where the ids of daemon containers are cached
	DaemonContainerBucket = "DaemonContainerCache"
	// ContainerIDTTL represents the time after that a daemon container will be renewed
	ContainerIDTTL = 10 * time.Minute
)
View Source
var (
	// RegistryBucket is the name of the bucket where local versions are cached
	RegistryBucket = "registryUpdateCache"
	// RegistryTTL represents the ttl after that a registry will be seen as outdated and will be updated
	RegistryTTL = 3 * time.Hour
)
View Source
var (
	// LocalVersionBucket is the name of the bucket where local versions are cached
	LocalVersionBucket = "localVersionCache"
	// RemoteVersionBucket is the name of the bucket where remote versions are cached
	RemoteVersionBucket = "remoteVersionCache"
	// RemoteTimeToLive is the duration that remote versions are valid.
	// Effectively this means we will check after the duration if a new version is available
	RemoteTimeToLive = 12 * time.Hour
	// LocalTimeToLive is the duration that local versions are valid.
	// Effectively this means we will check after the duration if a new version is available
	LocalTimeToLive = 1 * time.Minute
)
View Source
var (
	// ErrorNameRequired will be thrown, if Cache Entry key "Name" not set
	ErrorNameRequired = errors.New("Cache Entry Name not set")
)

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Versions  Version
	Container Container
	Registry  Registry
}

Cache is a struct that offers access to any cacheable item.

func New

func New(db config.Database) *Cache

New will return a new cache instance

type Container

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

Container represents the container cache. If the tool is daemonized then it can be that the daemon is already running. Normally it is then cached in the database. This provides a fast way to detect running daemons to a certain degree

func (*Container) Clear

func (c *Container) Clear(to tool.Tool, tag string) error

Clear will clear the entry of the given tool. This is useful if you want to clear things

func (*Container) ClearAll

func (c *Container) ClearAll() error

func (*Container) CurrentDaemons

func (c *Container) CurrentDaemons() (map[string]string, error)

CurrentDaemons will return all currently cached daemon tools. Useful to kill all currently running daemons.

func (*Container) Get

func (c *Container) Get(to tool.Tool, tag string, cfg *config.Config, mos []string) (string, error)

Get will return the id of the running container if possible

type Registry

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

Registry will store the time when the registry was updated the last time

func (*Registry) Clear

func (r *Registry) Clear(reg registry.Registry) error

Clear will clear the lastUpdate timestamp of the given registry

func (*Registry) ClearAll

func (c *Registry) ClearAll() error

func (*Registry) LastUpdate

func (r *Registry) LastUpdate(reg registry.Registry) (time.Time, error)

LastUpdate will return the last update of the registry. If the last update is older than the TTL it will update the registry

type Version

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

Version is the struct to work with cached versions

func (*Version) Clear

func (v *Version) Clear(to tool.Tool) error

Clear will clear the cached local and remote versions of this tool

func (*Version) ClearAll

func (c *Version) ClearAll() error

func (*Version) Local

func (v *Version) Local(to tool.Tool, client config.Docker) ([]string, error)

Local will return the remote versions of a tool from the cache if possible

func (*Version) Remote

func (v *Version) Remote(to tool.Tool) ([]string, error)

Remote will return the remote versions of a tool from the cache if possible

Jump to

Keyboard shortcuts

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