storage

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpired  = errors.New("record is expired")
	ErrNotFound = errors.New("record not found")
	ErrIO       = errors.New("io error")
)

Functions

func RegisterCache

func RegisterCache(name string, driver CacheDriver) error

func RegisterDB

func RegisterDB(name string, driver DBDriver) error

func RegisterFS

func RegisterFS(name string, driver FSDriver) error

func SetIsDev

func SetIsDev(isDevValue bool)

func SetLogger

func SetLogger(logger *logx.Logger)

Types

type Cache

type Cache interface {
	Has(key string) (bool, error)
	Get(key string) ([]byte, error)
	Set(key string, value []byte, ttl time.Duration) error
	Delete(key string) error
	Flush() error
}

func OpenCache

func OpenCache(url string) (cache Cache, err error)

New returns a new cache by url

type CacheDriver

type CacheDriver interface {
	Open(addr string, args url.Values) (cache Cache, err error)
}

type DB

type DB interface {
	Get(id string) (store Store, modtime time.Time, err error)
	Put(id string, category string, store Store) error
	List(category string) ([]ListItem, error)
	Delete(id string) error
	Close() error
}

func OpenDB

func OpenDB(url string) (DB, error)

type DBDriver

type DBDriver interface {
	Open(config string, options url.Values) (conn DB, err error)
}

type FS

type FS interface {
	Exists(path string) (found bool, size int64, modtime time.Time, err error)
	ReadFile(path string, size int64) (content io.ReadSeekCloser, err error)
	WriteFile(path string, r io.Reader) (written int64, err error)
	WriteData(path string, data []byte) error
}

func OpenFS

func OpenFS(fsUrl string) (FS, error)

type FSDriver

type FSDriver interface {
	Open(root string, options url.Values) (conn FS, err error)
}

type ListItem

type ListItem struct {
	Store  map[string]string `json:"store"`
	Motime uint32            `json:"modtime"`
}

type LocalLRUFS

type LocalLRUFS struct{}

func (*LocalLRUFS) Open

func (fs *LocalLRUFS) Open(root string, options url.Values) (FS, error)

type SimpleS3Client

type SimpleS3Client interface {
	Head(key *string) (*s3.HeadObjectOutput, error)
	Get(key *string) (*s3.GetObjectOutput, error)
	Put(key *string, body io.Reader) (*s3.PutObjectOutput, error)
	Delete(key *string) (*s3.DeleteObjectOutput, error)
	Download(key *string, size int64) (io.ReadSeekCloser, error)
	Upload(key *string, body io.Reader) error
}

func NewS3Client

func NewS3Client(simpleConfig *SimpleS3ClientConfig) (SimpleS3Client, error)

type SimpleS3ClientConfig

type SimpleS3ClientConfig struct {
	AccountId *string
	Bucket    *string
	Region    *string
	Log       *logx.Logger
}

type Store

type Store map[string]string

Jump to

Keyboard shortcuts

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