storage

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("object not found in database")
	ErrAlreadyExists = errors.New("object already exists in the database")
)

Functions

This section is empty.

Types

type APIKeyStorage added in v1.1.0

type APIKeyStorage interface {
	Register(*models.APIKey) error
	Retrieve(string) (*models.APIKey, error)
}

type LinkStorage added in v1.1.0

type LinkStorage interface {
	Save(*models.ShortURL) error
	List() ([]*models.ShortURL, error)
	Load(uint64) (string, error)
	LoadInfo(uint64) (*models.ShortURL, error)
	Delete(uint64) error
}

type Storage

type Storage interface {
	io.Closer
	LinkStorage
	APIKeyStorage
	StorageInfo
}

func Open

func Open(conf config.StorageConfig) (_ Storage, err error)

type StorageInfo added in v1.2.0

type StorageInfo interface {
	Counts() (*models.Counts, error)
}

type Store

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

func (*Store) Close

func (s *Store) Close() error

func (*Store) Counts added in v1.2.0

func (s *Store) Counts() (c *models.Counts, err error)

func (*Store) DB added in v1.1.0

func (s *Store) DB() *badger.DB

func (*Store) Delete

func (s *Store) Delete(key uint64) error

func (*Store) List added in v1.2.0

func (s *Store) List() ([]*models.ShortURL, error)

TODO: support pagination when listing links.

func (*Store) Load

func (s *Store) Load(key uint64) (string, error)

func (*Store) LoadInfo

func (s *Store) LoadInfo(key uint64) (*models.ShortURL, error)

func (*Store) Register added in v1.0.0

func (s *Store) Register(obj *models.APIKey) error

func (*Store) Retrieve added in v1.0.0

func (s *Store) Retrieve(clientID string) (*models.APIKey, error)

func (*Store) Save

func (s *Store) Save(obj *models.ShortURL) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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