rkv

package
v0.0.0-...-dde2e2b Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2014 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Key Value Storage with Revision

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRevNotMatch = errors.New("Revision Not Match")
)

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Get the Post of given Key.
	Get(key string) (Value, error)
	// Set the Post to the given Key.
	// Note that the revision of the new post must be increased by 1 from the old post.
	// If the length of the Content of the Post is zero, the post is considered safe to be deleted.
	Put(key string, p Value) error
}

func NewScopedStore

func NewScopedStore(source string, prefix string) (store Interface, err error)

func NewStore

func NewStore(source string) (store Interface, err error)

NewStore is a helper method for creating a built-in storage.

type MemStore

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

func NewMemStore

func NewMemStore() *MemStore

func (*MemStore) Get

func (m *MemStore) Get(key string) (Value, error)

func (*MemStore) Put

func (m *MemStore) Put(key string, np Value) error

type RediStore

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

func NewRediStore

func NewRediStore(addr string, db int) (*RediStore, error)

func (*RediStore) Get

func (r *RediStore) Get(key string) (v Value, err error)

func (*RediStore) Put

func (r *RediStore) Put(key string, p Value) error

type S

type S struct {
	Interface
}

S is Structured rkv. It's a layer on top of Interface for data structures. Currently the only

func (S) Read

func (s S) Read(key string, rev *int64, v interface{}) (err error)

func (S) ReadModify

func (s S) ReadModify(key string, v interface{}, mutate func(v interface{}) bool) (err error)

func (S) SetContain

func (s S) SetContain(key string, values ...string) (contain bool, err error)

SetContain return true if all values exists in the set.

func (S) SetDelete

func (s S) SetDelete(key string, values ...string) error

SetDelete will delete the given values from the key.

func (S) SetInsert

func (s S) SetInsert(key string, values ...string) error

SetInsert will insert the given values to the key.

func (S) SetSlice

func (s S) SetSlice(key, value string, before, after int) (slice []string, err error)

SetSlice return the slice around the value. Suppose the value is at position i, the returned slice will be [i-before:i+after]. If i == 0, the result will be [len-before:].

func (S) Write

func (s S) Write(key string, rev int64, v interface{}) (err error)

type SQLStore

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

func NewSQLStore

func NewSQLStore(driver, source, table string) (*SQLStore, error)

func (*SQLStore) Get

func (s *SQLStore) Get(key string) (Value, error)

func (*SQLStore) Put

func (s *SQLStore) Put(key string, np Value) error

type ScopedStore

type ScopedStore struct {
	Interface
	Prefix string
}

func (ScopedStore) Get

func (s ScopedStore) Get(key string) (Value, error)

func (ScopedStore) Put

func (s ScopedStore) Put(key string, v Value) error

type SortedString

type SortedString []string

SortedString is a list of sorted strings, mainly for indexing purpose. Note that the order of strings are defined by (len, content).

func SortedIntersect

func SortedIntersect(sss ...SortedString) (ret SortedString)

func SortedUnion

func SortedUnion(sss ...SortedString) (ret SortedString)

func (SortedString) Contain

func (s SortedString) Contain(v string) bool

func (*SortedString) Delete

func (s *SortedString) Delete(val string) bool

func (*SortedString) Insert

func (s *SortedString) Insert(val string) bool

func (SortedString) Len

func (s SortedString) Len() int

func (SortedString) Less

func (s SortedString) Less(i, j int) bool

func (SortedString) Search

func (s SortedString) Search(v string) int

func (SortedString) Slice

func (s SortedString) Slice(v string, before int, after int) SortedString

func (SortedString) Sort

func (s SortedString) Sort()

func (SortedString) Swap

func (s SortedString) Swap(i, j int)

func (*SortedString) Unique

func (s *SortedString) Unique()

type Value

type Value struct {
	Rev       int64
	Timestamp time.Time
	Content   []byte
}

Jump to

Keyboard shortcuts

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