storage

package
v1.3.0-policy Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: Apache-2.0 Imports: 6 Imported by: 4 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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