datastorage

package
v0.0.0-...-91c01a0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datastorer

type Datastorer interface {
	Save([]byte) error
	Load() ([]byte, error)
}

Datastorer reads and writes data to an object.

type GCPStorage

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

GCPStorage represents a Google Cloud Storage object.

func NewGCPStorage

func NewGCPStorage(bucket string, object string) *GCPStorage

NewGCPStorage returns a Google Cloud storage item given a bucket and an object path.

func (*GCPStorage) Load

func (s *GCPStorage) Load() ([]byte, error)

Load downloads an object from a bucket and returns an error if it cannot be read.

func (*GCPStorage) Save

func (s *GCPStorage) Save(b []byte) error

Save uploads an object to a bucket and returns an error if it cannot be written.

type LocalStorage

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

LocalStorage represents a file on the filesytem.

func NewLocalStorage

func NewLocalStorage(path string) *LocalStorage

NewLocalStorage returns a local storage object given a file path.

func (*LocalStorage) Load

func (s *LocalStorage) Load() ([]byte, error)

Load returns a file contents from the filesystem.

func (*LocalStorage) Save

func (s *LocalStorage) Save(b []byte) error

Save writes a file to the filesystem and returns an error if one occurs.

type Storage

type Storage struct {
	Site *stalecache.Cache[model.Site]
	// contains filtered or unexported fields
}

Storage represents a writable and readable object.

func New

func New(ds Datastorer) (*Storage, error)

New returns a writable and readable site object. Returns an error if the object cannot be initially read.

func (*Storage) InvalidateSite

func (s *Storage) InvalidateSite()

InvalidateSite invalidates the site cache and force a reload on next load.

func (*Storage) Save

func (s *Storage) Save(site *model.Site) error

Save writes the site object to the data storage and returns an error if it cannot be written.

Jump to

Keyboard shortcuts

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