database

package
v0.0.0-...-6438891 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JoinClusterFunc func()

Functions

func RegisterCommand

func RegisterCommand(name string, executor ExecFunc, cExecutor ClusterExecFunc, arity int)

RegisterCommand registers a new command arity means allowed number of cmdArgs, arity < 0 means len(args) >= -arity. for example: the arity of `get` is 2, `mget` is -2

Types

type ClusterDatabase

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

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

func NewClusterDB

func NewClusterDB(opt options.KuloyOptions) *ClusterDatabase

MakeClusterDatabase creates and starts a node of cluster

func (*ClusterDatabase) Close

func (cluster *ClusterDatabase) Close()

Close stops current node of cluster

func (*ClusterDatabase) Exec

func (cluster *ClusterDatabase) Exec(c *server.Conn, cmdLine [][]byte) (result reply.Reply)

Exec executes command on cluster

func (*ClusterDatabase) NotifyJoin

func (cluster *ClusterDatabase) NotifyJoin(n *memberlist.Node)

func (*ClusterDatabase) NotifyLeave

func (cluster *ClusterDatabase) NotifyLeave(n *memberlist.Node)

func (*ClusterDatabase) NotifyUpdate

func (cluster *ClusterDatabase) NotifyUpdate(n *memberlist.Node)

type ClusterEventHandler

type ClusterEventHandler struct{}

type ClusterExecFunc

type ClusterExecFunc func(cluster *ClusterDatabase, c *server.Conn, cmdAndArgs [][]byte) reply.Reply

ClusterExecFunc represents the handler of a redis command

type CmdLine

type CmdLine = [][]byte

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

type DataEntity

type DataEntity struct {
	Data    []byte
	KeyType KeyType
}

DataEntity stores data bound to a key, including a string, list, hash, set and so on

type Database

type Database interface {
	Exec(c *server.Conn, args [][]byte) reply.Reply
	Close()
}

Database is the interface for redis style storage engine

type ExecFunc

type ExecFunc func(db *SingleDB, args [][]byte) reply.Reply

ExecFunc is interface for command executor args don't include cmd line

type KeyType

type KeyType byte
const (
	STRING_TYPE KeyType = iota
	LIST_TYPE
	HASH_TYPE
	SET_TYPE
	SORTSET_TYPE
	BITMAP_TYPE
)

type MutilDB

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

MutilDB is a set of multiple database set

func NewMutilDB

func NewMutilDB(opt CouloyDB.Options) *MutilDB

NewDatabase creates a redis database,

func (*MutilDB) Close

func (mdb *MutilDB) Close()

Close graceful shutdown database

func (*MutilDB) Exec

func (mdb *MutilDB) Exec(c *server.Conn, cmdLine [][]byte) (result reply.Reply)

Exec executes command parameter `cmdLine` contains command and its arguments, for example: "set key value"

type SingleDB

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

DB stores data and execute user's commands

func NewSingleDB

func NewSingleDB(opt CouloyDB.Options) *SingleDB

NewSingleDB create single DB instance

func (*SingleDB) CheckIsExist

func (db *SingleDB) CheckIsExist(key string) bool

CheckIsExist check the given key from db if exist

func (*SingleDB) Close

func (db *SingleDB) Close()

func (*SingleDB) Exec

func (db *SingleDB) Exec(c *server.Conn, cmdLine [][]byte) reply.Reply

Exec executes command within one database

func (*SingleDB) Flush

func (db *SingleDB) Flush()

Flush clean database

func (*SingleDB) GetEntity

func (db *SingleDB) GetEntity(key string) (*DataEntity, bool)

GetEntity returns DataEntity bind to given key

func (*SingleDB) PutEntity

func (db *SingleDB) PutEntity(key string, entity *DataEntity) int

PutEntity a DataEntity into DB

func (*SingleDB) PutIfAbsent

func (db *SingleDB) PutIfAbsent(key string, entity *DataEntity) int

PutIfAbsent insert an DataEntity only if the key not exists

func (*SingleDB) PutIfExists

func (db *SingleDB) PutIfExists(key string, entity *DataEntity) int

PutIfExists edit an existing DataEntity

func (*SingleDB) Remove

func (db *SingleDB) Remove(key string)

Remove the given key from db

func (*SingleDB) Removes

func (db *SingleDB) Removes(keys ...string) (deleted int)

Removes the given keys from db

Directories

Path Synopsis
datastruct

Jump to

Keyboard shortcuts

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