cache

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateTable = `` /* 177-byte string literal not displayed */
View Source
var ErrEntryNotFound = errors.New("entry not found")
View Source
var Now = time.Now

Functions

func ComputeCacheID added in v0.3.1

func ComputeCacheID(path string) (id string)

Types

type Cache

type Cache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewCache

func NewCache(location string) (c *Cache, err error)

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) Get

func (c *Cache) Get(id string) (entry *Entry, err error)

func (*Cache) GetBySha256 added in v0.3.1

func (c *Cache) GetBySha256(sha256 string) (entry *Entry, err error)

func (*Cache) Set

func (c *Cache) Set(entry *Entry) (err error)

type Cacher

type Cacher interface {
	// Set adds or updates a cache entry
	Set(entry *Entry) error

	// Get fetch a cache entry
	Get(id string) (entry *Entry, err error)
	GetBySha256(sha256 string) (entry *Entry, err error)

	Close() error
}

type Entry

type Entry struct {
	ID        string    `gorm:"primarykey" field:"id"`
	Sha256    string    `field:"sha256"`
	CreatedAt time.Time `field:"created_at"`
	UpdatedAt time.Time `field:"updated_at"`
	// DeletedAt          gorm.DeletedAt `gorm:"index"`
	InitialLocation    string    `field:"location"`
	QuarantineLocation string    `field:"quarantine"`
	RestoredAt         time.Time `field:"restored_at"`
}

type MockCache

type MockCache struct {
	SetMock   func(entry *Entry) error
	GetMock   func(id string) (entry *Entry, err error)
	CloseMock func() error
}

func (*MockCache) Close

func (m *MockCache) Close() error

func (*MockCache) Get

func (m *MockCache) Get(id string) (*Entry, error)

func (*MockCache) GetBySha256 added in v0.3.1

func (m *MockCache) GetBySha256(id string) (*Entry, error)

func (*MockCache) Set

func (m *MockCache) Set(entry *Entry) error

Jump to

Keyboard shortcuts

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