store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type S

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

S is an in-memory key-value store, where all changes are made via Raft consensus.

func New

func New(raftDir, hostAddr string, members []string) *S

New returns a new in-memory Store.

func (*S) Close

func (s *S) Close() error

Close shuts down raft and store http server

func (*S) Count

func (s *S) Count() int

func (*S) Delete

func (s *S) Delete(key string) error

Delete deletes the given key. If it gets called on a follower node the request will be forwarded to the leader.

func (*S) Get

func (s *S) Get(key string) (interface{}, bool)

Get returns the value for the given key.

func (*S) Open

func (s *S) Open() error

Open opens the store. If and there are no existing peers, meaning there is not a formed cluster, then this node becomes the first node, and therefore leader, of the cluster.

func (*S) Set

func (s *S) Set(key string, value interface{}) error

Set sets the value for the given key. If it gets called on a follower node the request will be forwarded to the leader.

Jump to

Keyboard shortcuts

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