store

package
v0.0.0-...-2bedc2f Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound   = errors.New("key not found")
	ErrImageNotFound = errors.New("image not found")
)

Functions

This section is empty.

Types

type DataStore

type DataStore interface {
	Get(key string) ([]byte, error)
	Set(key string, value []byte) error
	Delete(key string) error
	// GenerateId generates a unique id for the store
	GenerateId() (string, error)
}

DataStore is an interface for storing and retrieving data from a key value store

type DiskDataStore

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

func NewDiskDataStore

func NewDiskDataStore(filePath string) (*DiskDataStore, error)

func (*DiskDataStore) Delete

func (d *DiskDataStore) Delete(key string) error

func (*DiskDataStore) GenerateId

func (d *DiskDataStore) GenerateId() (string, error)

func (*DiskDataStore) Get

func (d *DiskDataStore) Get(key string) ([]byte, error)

func (*DiskDataStore) Set

func (d *DiskDataStore) Set(key string, value []byte) error

type DiskImageStore

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

func NewDiskImageStore

func NewDiskImageStore(rootPath string) *DiskImageStore

NewDiskImageStore creates a new DiskImageStore that stores images in the given rootPath. If you want to use this to actually serve files, this should be a path you expose as part of your server

func (*DiskImageStore) Delete

func (d *DiskImageStore) Delete(container string, id string) error

func (*DiskImageStore) Get

func (d *DiskImageStore) Get(container string, id string) (*url.URL, error)

func (*DiskImageStore) Set

func (d *DiskImageStore) Set(container string, id string, expected_length uint, value io.ReadCloser) (*url.URL, error)

type ImageStore

type ImageStore interface {
	// Get an image from the store, returning the URL to the image, but not the image itself. This
	// allows an implementation to do things like generate a token to a CDN
	Get(container string, id string) (*url.URL, error)
	// Set an image to the store, returning the URL to the image. This allows an implementation
	// to do things like generating a token to a CDN
	Set(container string, id string, expected_length uint, value io.ReadCloser) (*url.URL, error)
	Delete(container string, id string) error
}

Jump to

Keyboard shortcuts

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