storage

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound key not found in store

Functions

This section is empty.

Types

type Deserializer

type Deserializer func([]byte) (interface{}, error)

Deserializer interface to tell storage how to deserialize

type DiskStorage

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

DiskStorage persistence storage on disk

func (*DiskStorage) Delete

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

Delete key in disk storage

func (*DiskStorage) Get

func (d *DiskStorage) Get(key string) (interface{}, error)

Get value in disk storage

func (*DiskStorage) List

func (d *DiskStorage) List() ([]interface{}, error)

List values in disk storage

func (*DiskStorage) Put

func (d *DiskStorage) Put(key string, value interface{}) error

Put somethings into disk storage

type MemoryStorage

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

MemoryStorage is in memory storage

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

NewMemoryStorage return new in memory storage

func (*MemoryStorage) Delete

func (m *MemoryStorage) Delete(key string) error

Delete key in memory storage

func (*MemoryStorage) Get

func (m *MemoryStorage) Get(key string) (interface{}, error)

Get value in memory storage

func (*MemoryStorage) List

func (m *MemoryStorage) List() ([]interface{}, error)

List values in memory storage

func (*MemoryStorage) Put

func (m *MemoryStorage) Put(key string, value interface{}) error

Put somethings into memory storage

type Serializer

type Serializer func(interface{}) ([]byte, error)

Serializer interface to tell storage how to serialize object

type Storage

type Storage interface {
	Put(key string, value interface{}) error
	Get(key string) (interface{}, error)
	List() ([]interface{}, error)
	Delete(key string) error
}

Storage persistent storage on disk

func NewDiskStorage

func NewDiskStorage(name string, path string, serializer Serializer, deserializer Deserializer) (Storage, error)

NewDiskStorage return new disk storage

Jump to

Keyboard shortcuts

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