go-store: github.com/gosuri/go-store/store Index | Files

package store

import "github.com/gosuri/go-store/store"

Package store provides platform-independent interfaces to persist and retrieve data.

Its primary job is to wrap existing implementations of such primitives, such as those in package redis, into shared public interfaces that abstract functionality, plus some other related primitives.

Because these interfaces and primitives wrap lower-level operations with various implementations, unless otherwise informed clients should not assume they are safe for parallel execution.

Index

Package Files

store.go

Variables

var ErrEmptyKey = errors.New("store: key is empty")

ErrEmptyKey means that the key for the object provided is empty

var ErrKeyNotFound = errors.New("store: key not found")

ErrKeyNotFound means that the object associated with the key is not found in the datastore

type Deleter Uses

type Deleter interface {
    Delete(i Item) error
}

Deleter is the interface that wraps the basic Delete method.

Delete deletes i from the underlying datastore. It returns any error encountered that prevented the deletion from occurring.

type Item Uses

type Item interface {
    Key() string
    SetKey(string)
}

Item is the interface that wraps Key and SetKey methods.

Key returns a unique idenfier for the item from the implementation. It is called by the implementing store when retrieving objects from its underlying store.

SetKey sets the item key. It is called by the store when Unmarshalling objects from its underlying store.

The below example illustrates usage:

type Hacker struct {
	Id        string
	Name      string
	Birthyear int
}

func (h *Hacker) Key() string {
	return h.Id
}

func (h *Hacker) SetKey(k string) {
	h.Id = k
}

type Lister Uses

type Lister interface {
    List(interface{}) error
}

Lister is the interface that wraps the basic List method.

type MultiDeleter Uses

type MultiDeleter interface {
    DeleteMultiple(items []Item) (int, error)
}

MultiDeleter is the interface that wraps DeleteMultiple method.

type MultiReadWriter Uses

type MultiReadWriter interface {
    MultiReader
    MultiWriter
    MultiDeleter
}

MultiReadWriter is the interface that groups MultiReader and MultiWriter interfaces.

type MultiReader Uses

type MultiReader interface {
    ReadMultiple(interface{}) error
}

MultiReader is the interface that wraps ReadMultiple method.

type MultiWriter Uses

type MultiWriter interface {
    WriteMultiple(items []Item) error
}

MultiWriter is the interface that wraps WriteMultiple method.

type ReadWriter Uses

type ReadWriter interface {
    Reader
    Writer
    Deleter
}

ReadWriter is the interface that groups Reader, Writer and Deleter interfaces.

type Reader Uses

type Reader interface {
    Read(i Item) error
}

Reader is the interface that wraps the basic Read method.

Read reads i from the underlying data store and copies to i. It returns any error encountered that caused the write to stop early.

type Store Uses

type Store interface {
    ReadWriter
    Lister
    MultiReadWriter
}

Store is the interface to store implemented in package redis. It groups ReadWriter, Lister and MultiReader interfaces.

type Writer Uses

type Writer interface {
    Write(i Item) error
}

Writer is the interface that wraps the basic Write method.

Write writes i to the underlying data store. It expects i.Key method to return a unique identifier for the item, it will otherwise generate a unique identifier and calls i.SetKey method. It returns any error encountered that caused the write to stop early.

Package store imports 1 packages (graph) and is imported by 1 packages. Updated 2016-07-30. Refresh now. Tools for package owners.