cache

package
v0.0.0-...-0d651c5 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CacheRegion permits to access at the region field
	CacheRegion = iota
	// CacheArch permits to access at the arch field
	CacheArch
	// CacheOwner permits to access at the owner field
	CacheOwner
	// CacheTitle permits to access at the title field
	CacheTitle
	// CacheMarketPlaceUUID is used to determine the UUID of local images
	CacheMarketPlaceUUID
	// CacheMaxfield is used to determine the size of array
	CacheMaxfield
)

Variables

This section is empty.

Functions

func ComputeRankMatch

func ComputeRankMatch(s *types.ScalewayResolverResult, needle string)

ComputeRankMatch fills `ScalewayResolverResult.RankMatch` with its `fuzzy` score

Types

type ScalewayCache

type ScalewayCache struct {
	// Images contains names of Scaleway images indexed by identifier
	Images map[string][CacheMaxfield]string `json:"images"`

	// Snapshots contains names of Scaleway snapshots indexed by identifier
	Snapshots map[string][CacheMaxfield]string `json:"snapshots"`

	// Volumes contains names of Scaleway volumes indexed by identifier
	Volumes map[string][CacheMaxfield]string `json:"volumes"`

	// Bootscripts contains names of Scaleway bootscripts indexed by identifier
	Bootscripts map[string][CacheMaxfield]string `json:"bootscripts"`

	// Servers contains names of Scaleway servers indexed by identifier
	Servers map[string][CacheMaxfield]string `json:"servers"`

	// Path is the path to the cache file
	Path string `json:"-"`

	// Modified tells if the cache needs to be overwritten or not
	Modified bool `json:"-"`

	// Lock allows ScalewayCache to be used concurrently
	Lock sync.Mutex `json:"-"`
	// contains filtered or unexported fields
}

ScalewayCache is used not to query the API to resolve full identifiers

func NewScalewayCache

func NewScalewayCache(hookSave func()) (*ScalewayCache, error)

NewScalewayCache loads a per-user cache

func (*ScalewayCache) Clear

func (c *ScalewayCache) Clear()

Clear removes all information from the cache

func (*ScalewayCache) ClearBootscripts

func (c *ScalewayCache) ClearBootscripts()

ClearBootscripts removes all bootscripts from the cache

func (*ScalewayCache) ClearImages

func (c *ScalewayCache) ClearImages()

ClearImages removes all images from the cache

func (*ScalewayCache) ClearServers

func (c *ScalewayCache) ClearServers()

ClearServers removes all servers from the cache

func (*ScalewayCache) ClearSnapshots

func (c *ScalewayCache) ClearSnapshots()

ClearSnapshots removes all snapshots from the cache

func (*ScalewayCache) ClearVolumes

func (c *ScalewayCache) ClearVolumes()

ClearVolumes removes all volumes from the cache

func (*ScalewayCache) Flush

func (c *ScalewayCache) Flush() error

Flush flushes the cache database

func (*ScalewayCache) GetNbBootscripts

func (c *ScalewayCache) GetNbBootscripts() int

GetNbBootscripts returns the number of bootscripts in the cache

func (*ScalewayCache) GetNbImages

func (c *ScalewayCache) GetNbImages() int

GetNbImages returns the number of images in the cache

func (*ScalewayCache) GetNbServers

func (c *ScalewayCache) GetNbServers() int

GetNbServers returns the number of servers in the cache

func (*ScalewayCache) GetNbSnapshots

func (c *ScalewayCache) GetNbSnapshots() int

GetNbSnapshots returns the number of snapshots in the cache

func (*ScalewayCache) GetNbVolumes

func (c *ScalewayCache) GetNbVolumes() int

GetNbVolumes returns the number of volumes in the cache

func (*ScalewayCache) InsertBootscript

func (c *ScalewayCache) InsertBootscript(identifier, region, arch, owner, name string)

InsertBootscript registers an bootscript in the cache

func (*ScalewayCache) InsertImage

func (c *ScalewayCache) InsertImage(identifier, region, arch, owner, name, marketPlaceUUID string)

InsertImage registers an image in the cache

func (*ScalewayCache) InsertServer

func (c *ScalewayCache) InsertServer(identifier, region, arch, owner, name string)

InsertServer registers a server in the cache

func (*ScalewayCache) InsertSnapshot

func (c *ScalewayCache) InsertSnapshot(identifier, region, arch, owner, name string)

InsertSnapshot registers an snapshot in the cache

func (*ScalewayCache) InsertVolume

func (c *ScalewayCache) InsertVolume(identifier, region, arch, owner, name string)

InsertVolume registers an volume in the cache

func (*ScalewayCache) LookUpBootscripts

func (c *ScalewayCache) LookUpBootscripts(needle string, acceptUUID bool) (types.ScalewayResolverResults, error)

LookUpBootscripts attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpIdentifiers

func (c *ScalewayCache) LookUpIdentifiers(needle string) (types.ScalewayResolverResults, error)

LookUpIdentifiers attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpImages

func (c *ScalewayCache) LookUpImages(needle string, acceptUUID bool) (types.ScalewayResolverResults, error)

LookUpImages attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpServers

func (c *ScalewayCache) LookUpServers(needle string, acceptUUID bool) (types.ScalewayResolverResults, error)

LookUpServers attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpSnapshots

func (c *ScalewayCache) LookUpSnapshots(needle string, acceptUUID bool) (types.ScalewayResolverResults, error)

LookUpSnapshots attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpVolumes

func (c *ScalewayCache) LookUpVolumes(needle string, acceptUUID bool) (types.ScalewayResolverResults, error)

LookUpVolumes attempts to return identifiers matching a pattern

func (*ScalewayCache) RemoveBootscript

func (c *ScalewayCache) RemoveBootscript(identifier string)

RemoveBootscript removes a bootscript from the cache

func (*ScalewayCache) RemoveImage

func (c *ScalewayCache) RemoveImage(identifier string)

RemoveImage removes a server from the cache

func (*ScalewayCache) RemoveServer

func (c *ScalewayCache) RemoveServer(identifier string)

RemoveServer removes a server from the cache

func (*ScalewayCache) RemoveSnapshot

func (c *ScalewayCache) RemoveSnapshot(identifier string)

RemoveSnapshot removes a server from the cache

func (*ScalewayCache) RemoveVolume

func (c *ScalewayCache) RemoveVolume(identifier string)

RemoveVolume removes a server from the cache

func (*ScalewayCache) Save

func (c *ScalewayCache) Save() error

Save atomically overwrites the current cache database

Jump to

Keyboard shortcuts

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