storage

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseExistsError

type DatabaseExistsError struct {
	Identifier string
}

DatabaseExistsError is returned when a database already exists when trying to create it

func (DatabaseExistsError) Error

func (e DatabaseExistsError) Error() string

type DatabaseNotFoundError

type DatabaseNotFoundError struct {
	Identifier string
}

DatabaseNotFoundError is returned when a database is not found

func (DatabaseNotFoundError) Error

func (e DatabaseNotFoundError) Error() string

type Engine

type Engine interface {
	// Get gets a value from the database using a byte key
	GetBytes(identifier string, key key.Key) ([]byte, error)
	// GetBytesSafe attempts to get a value from the database, and returns nil if not found
	GetBytesSafe(identifier string, key key.Key) ([]byte, error)
	// SetBytes sets a value in the database using a byte key
	SetBytes(identifier string, key key.Key, value []byte) error
	// Close closes the database
	Close() error
	// GetDBFileName returns the on-disk filename of the database
	GetDBFileName() string
}

Engine is an interface for a storage engine, backed by some database for persistence

type EngineCache

type EngineCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

EngineCache is a collection of storage engine objects currently loaded into RAM

func NewCacheMap

func NewCacheMap() *EngineCache

NewCacheMap returns a new StorageLayerCacheMap object

func (*EngineCache) All

func (sm *EngineCache) All() map[string]Engine

All retrieves all StorageLayer objects from the collection

func (*EngineCache) Clear

func (sm *EngineCache) Clear()

Clear removes all StorageLayer objects from the cache collection

func (*EngineCache) Delete

func (sm *EngineCache) Delete(identifier string)

Delete removes a StorageLayer object from the cache collection

func (*EngineCache) Get

func (sm *EngineCache) Get(identifier string) (Engine, bool)

Get retrieves a StorageLayer from the collection, and a boolean indicating if it was found

func (*EngineCache) Len

func (sm *EngineCache) Len() int

Len returns the number of StorageLayer objects in the cache collection

func (*EngineCache) Put

func (sm *EngineCache) Put(identifier string, db Engine)

Put adds a new StorageLayer object to this in-memory collection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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