store

package
v0.0.0-...-34de315 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encode(w io.Writer, i interface{}) error
	Decode(r io.Reader) (interface{}, error)
}

Codec serializes and deserializes entities.

type KV

type KV interface {
	Put(key []byte, val []byte) error
	Has(key []byte) (bool, error)
	Get(key []byte) ([]byte, error)
	Del(key []byte) error
}

KV represents a common wrapper around a key-value database.

type Store

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

Store represents a store to store entities by unique ID.

func New

func New(kv KV, codec Codec, prefix string) *Store

New creates a new store for entities, using the given codec to encode them, the key-value store to save the data and the prefix to add to the key for differentiation with other entities in the same store.

func (*Store) Retrieve

func (s *Store) Retrieve(hash types.Hash) (interface{}, error)

Retrieve will retrieve an entity from the store.

func (*Store) Save

func (s *Store) Save(hash types.Hash, entity interface{}) error

Save will put a new entity into the store.

Jump to

Keyboard shortcuts

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