storage

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

DEPRECATED: This package is deprecated and will be removed in a future release.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(path string)

Open opens singleton connection to storage.

If an error occurs during execution, the program terminates with code 2 and the error will be written in os.Stderr.

Should be used only once while application is starting.

Types

type Storage

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

Storage represents the main storage based on badger.DB.

func GetStorage

func GetStorage() *Storage

GetStorage returns current storage implementation.

func (*Storage) Close

func (s *Storage) Close() error

Close closes a DB.

func (*Storage) Del

func (s *Storage) Del(key []byte) error

Del deletes entry by the key.

func (*Storage) Get

func (s *Storage) Get(key []byte) (value []byte, err error)

Get retrieves entry by the key.

func (*Storage) Iterate

func (s *Storage) Iterate(handler func(item *badger.Item) error, prefix []byte) error

Iterate iterates all elements with provided prefix and processes it with the handler.

func (*Storage) NewTransaction

func (s *Storage) NewTransaction(update bool) *badger.Txn

NewTransaction creates new badger.Txn.

For read-only transactions set update flag to false.

func (*Storage) Set

func (s *Storage) Set(key []byte, value Value) error

Set sets encoded Value with provided key.

func (*Storage) SetWithRetries

func (s *Storage) SetWithRetries(key []byte, value Value, numRetries int) error

SetWithRetries sets encoded Value with provided key with retries.

type Value

type Value interface {
	Encode() []byte
}

Value represent value that can be stored as encoded bytes.

Jump to

Keyboard shortcuts

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