cache

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: GPL-3.0 Imports: 8 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupBolt

func SetupBolt(path string, l logging.Logger) error

SetupBolt opens a boltdb and creates a meta bucket if not exists.

Types

type Bolt

type Bolt struct {
	Path string
	Log  logging.Logger
	// contains filtered or unexported fields
}

Bolt holds a pointer of bolt.DB boltdb is used to store a cache of Changelogs of Ubuntu/Debian

func (Bolt) Close

func (b Bolt) Close() error

Close a db.

func (Bolt) EnsureBuckets

func (b Bolt) EnsureBuckets(meta Meta) error

EnsureBuckets puts a Meta information and create a bucket that holds changelogs.

func (Bolt) GetChangelog

func (b Bolt) GetChangelog(servername, packName string) (changelog string, err error)

GetChangelog get the changelog of specified packName from the Bucket

func (Bolt) GetMeta

func (b Bolt) GetMeta(serverName string) (meta Meta, found bool, err error)

GetMeta gets a Meta Information os the servername to boltdb.

func (Bolt) PrettyPrint

func (b Bolt) PrettyPrint(meta Meta) error

PrettyPrint is for debug

func (Bolt) PutChangelog

func (b Bolt) PutChangelog(servername, packName, changelog string) error

PutChangelog put the changelog of specified packName into the Bucket

func (Bolt) RefreshMeta added in v0.3.0

func (b Bolt) RefreshMeta(meta Meta) error

RefreshMeta gets a Meta Information os the servername to boltdb.

type Cache

type Cache interface {
	Close() error
	GetMeta(string) (Meta, bool, error)
	RefreshMeta(Meta) error
	EnsureBuckets(Meta) error
	PrettyPrint(Meta) error
	GetChangelog(string, string) (string, error)
	PutChangelog(string, string, string) error
}

Cache is a interface of cache

var DB Cache

DB has a cache instance

type Meta

type Meta struct {
	Name      string
	Distro    config.Distro
	Packs     models.Packages
	CreatedAt time.Time
}

Meta holds a server name, distro information of the scanned server and package information that was collected at the last scan.

Jump to

Keyboard shortcuts

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