Documentation
¶
Overview ¶
Package cache handles the caching of the downloaded items.
Index ¶
- Variables
- type Cache
- func (c *Cache) Add(items ...*Item) error
- func (c *Cache) Delete(identifiers ...string) error
- func (c *Cache) DeleteByName(names ...string) error
- func (c *Cache) Get(identifiers ...string) ([]*Item, error)
- func (c *Cache) GetByName(names ...string) ([]*Item, error)
- func (c *Cache) IsEmpty() bool
- func (c *Cache) Load() error
- func (c *Cache) Touched() bool
- type Item
- type Items
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrItemNotFound = errors.New("item not found")
ErrItemNotFound is returned when an item is not found in the cache.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
file.File // embedded file.File for cache operations
// contains filtered or unexported fields
}
Cache is a cache backend that stores data in a JSON file.
func (*Cache) Delete ¶
Delete removes items from the cache by identifier. If no identifiers are provided, it deletes all items in the cache.
func (*Cache) DeleteByName ¶ added in v0.0.13
DeleteByName removes items from the cache by name. If no names are provided, it deletes all items in the cache.
func (*Cache) Get ¶
Get retrieves items from the cache by ID. If no identifiers are provided, it returns all items in the cache.
type Item ¶
type Item struct {
// ID is the unique identifier of the item.
ID string `json:"id"`
// Name is the name of the item.
Name string `json:"name"`
// Path is the file path of the item.
Path string `json:"path"`
// Type is the type of the item.
Type string `json:"type"`
// Version of the item.
Version version.Version `json:"version"`
// Downloaded is the time when the item was downloaded.
Downloaded time.Time `json:"downloaded"`
// Updated is the time when the item was last updated.
Updated time.Time `json:"updated"`
}
Item represents a cache item.
Click to show internal directories.
Click to hide internal directories.