store

package
v0.0.0-...-50a54d8 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

包存储提供了一个简单的分布式键值存储。 密钥和相关联的值通过分布式一致性进行更改,这意味着只有当集群中的大多数节点同意新值时,这些值才会更改。

分布式一致性是通过Raft算法提供的,特别是Hashicorp实现。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	RaftDir  string
	RaftBind string
	// contains filtered or unexported fields
}

Store是一个简单的关键价值存储,所有的改变都是通过Raft协商一致来实现的。

func New

func New(inmem bool) *Store

New returns a new Store.

func (*Store) Delete

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

Delete deletes the given key.

func (*Store) Get

func (s *Store) Get(key string) (string, error)

Get returns the value for the given key.

func (*Store) Join

func (s *Store) Join(nodeID, addr string) error

加入一个node节点, 由nodeID标识和addr地址. 节点必须准备好响应该地址的Raft通信。

func (*Store) Open

func (s *Store) Open(enableSingle bool, localID string) error

打开存储。如果enableSingle被设置,并且没有现有的对等体,那么这个节点成为集群的第一个节点,并因此成为集群的领导者。 localID应该是此节点的服务器标识符。

func (*Store) Set

func (s *Store) Set(key, value string) error

Set sets the value for the given key.

Jump to

Keyboard shortcuts

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