storage

package
Version: v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Deserializer

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

type DiskStorage

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

func (*DiskStorage) Delete

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

func (*DiskStorage) Get

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

func (*DiskStorage) List

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

func (*DiskStorage) Put

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

type MemoryStorage

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

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

func (*MemoryStorage) Delete

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

func (*MemoryStorage) Get

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

func (*MemoryStorage) List

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

func (*MemoryStorage) Put

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

type Serializer

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

type Storage

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

可靠存储,数据一旦存储之后就不会丢失

func NewDiskStorage

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

Source Files

Jump to

Keyboard shortcuts

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