cluster

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package cluster provides a server side cluster which is transparent to client. You can connect to any node in the cluster to access all data in the cluster

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy added in v1.2.9

func Copy(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

Copy copies the value stored at the source key to the destination key. the origin and the destination must within the same node.

func Del

func Del(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

Del atomically removes given writeKeys from cluster, writeKeys can be distributed on any node if the given writeKeys are distributed on different node, Del will use try-commit-catch to remove them

func FlushAll

func FlushAll(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

FlushAll removes all data in cluster

func FlushDB

func FlushDB(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

FlushDB removes all data in current database

func MGet

func MGet(cluster *Cluster, c redis.Connection, cmdLine CmdLine) redis.Reply

MGet atomically get multi key-value from cluster, writeKeys can be distributed on any node

func MSet

func MSet(cluster *Cluster, c redis.Connection, cmdLine CmdLine) redis.Reply

MSet atomically sets multi key-value in cluster, writeKeys can be distributed on any node

func MSetNX

func MSetNX(cluster *Cluster, c redis.Connection, cmdLine CmdLine) redis.Reply

MSetNX sets multi key-value in database, only if none of the given writeKeys exist and all given writeKeys are on the same node

func Publish

func Publish(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

Publish broadcasts msg to all peers in cluster when receive publish command from client

func Rename

func Rename(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

Rename renames a key, the origin and the destination must within the same node

func RenameNx

func RenameNx(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

RenameNx renames a key, only if the new key does not exist. The origin and the destination must within the same node

func Subscribe

func Subscribe(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

Subscribe puts the given connection into the given channel

func UnSubscribe

func UnSubscribe(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

UnSubscribe removes the given connection from the given channel

Types

type Cluster

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

Cluster represents a node of godis cluster it holds part of data and coordinates other nodes to finish transactions

func MakeCluster

func MakeCluster() *Cluster

MakeCluster creates and starts a node of cluster

func (*Cluster) AfterClientClose

func (cluster *Cluster) AfterClientClose(c redis.Connection)

AfterClientClose does some clean after client close connection

func (*Cluster) Close

func (cluster *Cluster) Close()

Close stops current node of cluster

func (*Cluster) Exec

func (cluster *Cluster) Exec(c redis.Connection, cmdLine [][]byte) (result redis.Reply)

Exec executes command on cluster

func (*Cluster) LoadRDB added in v1.2.9

func (cluster *Cluster) LoadRDB(dec *core.Decoder) error

type CmdFunc

type CmdFunc func(cluster *Cluster, c redis.Connection, cmdLine CmdLine) redis.Reply

CmdFunc represents the handler of a redis command

type CmdLine added in v1.2.7

type CmdLine = [][]byte

CmdLine is alias for [][]byte, represents a command line

type PeerPicker added in v1.2.8

type PeerPicker interface {
	AddNode(keys ...string)
	PickNode(key string) string
}

type Transaction

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

Transaction stores state and data for a try-commit-catch distributed transaction

func NewTransaction

func NewTransaction(cluster *Cluster, c redis.Connection, id string, cmdLine [][]byte) *Transaction

NewTransaction creates a try-commit-catch distributed transaction

Jump to

Keyboard shortcuts

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