gokv

package module
v0.0.0-...-3408d66 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

README

GoKV is a package which implements a unified interface for various Golang based key/value stores.

Current drivers include:

More drivers are most welcome! Just make sure they meet at least the "kv".Store interface and are unit tested.

Documentation

Overview

Package gokv implements a set of drivers and a common interface for working with different key/value storage systems

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client is a cache client with built in replication to any number of different caches. This allows replication and syncronization across various caches using the set of drivers available as subpackages, including Memcached, Redis, in-memory caches, and more.

func New

func New() *Client

New returns a new initialized cache Client with no nodes.

func (*Client) AddNode

func (c *Client) AddNode(name string, node kv.Store) error

AddNode adds a cache node with the given name, but only if it doesn't already exist

func (*Client) Del

func (c *Client) Del(key string) (err error)

Del implements the "kv.Store".Del() interface. It deletes the given key across all replicated nodes and returns error if any of those delete operations fail.

func (*Client) Get

func (c *Client) Get(key string, dstVal interface{}) (err error)

Get implements the "kv.Store".Get() interface. It checks nodes in order of priority, and returns success if the value exists on any of them.

func (*Client) RemoveNode

func (c *Client) RemoveNode(name string) error

RemoveNode removes a node with the given name from the node list

func (*Client) ReplaceNode

func (c *Client) ReplaceNode(name string, node kv.Store) error

ReplaceNode adds a cache node with the given name, but only if it already exists

func (*Client) ReplicateToN

func (c *Client) ReplicateToN(numNodes int) error

ReplicateToN sets how many nodes each key should be replicated to

func (*Client) Set

func (c *Client) Set(key string, value interface{}) (err error)

Set implements the "kv.Store".Set() interface

func (*Client) SetNode

func (c *Client) SetNode(name string, node kv.Store) error

SetNode sets the cache node with the given name, regardless of whether it already exists or not

func (*Client) SetReplicateMethod

func (c *Client) SetReplicateMethod(m ReplicationMethod)

SetReplicateMethod sets the replication method

type ReplicationMethod

type ReplicationMethod int

ReplicationMethod determines whether replication takes place asyncronously or syncronously. Use ReplicateAsync for asyncronous replication, ReplicateSync for syncronous replication.

const (
	// ReplicateAsync indicates that replication will be done asyncronously.
	// Set commands will return without error as soon as at least one node has
	// the value
	ReplicateAsync ReplicationMethod = iota

	// ReplicateSync indicates that replication will be done syncronously.
	// Set commands will return without error only if all nodes return without error
	ReplicateSync = iota
)

Directories

Path Synopsis
drivers

Jump to

Keyboard shortcuts

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