cmd

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const INFINITE_EXPIRATION = int64(-1)

nolint: stylecheck

View Source
const (
	MaxEXDurationSec = 365 * 24 * 60 * 60 // 1 year in seconds
)
View Source
const PERSIST = "PERSIST"

Variables

View Source
var (
	EXISTSResNilRes = newEXISTSRes(0)
	EXISTSResOKRes  = newEXISTSRes(1)
)
View Source
var (
	EXPIREResNilRes    = newEXPIRERes(false)
	EXPIREResSetRes    = newEXPIRERes(true)
	EXPIREResNotSetRes = newEXPIRERes(false)
)
View Source
var (
	EXPIREATResNilRes       = newEXPIREATRes(false)
	EXPIREATResChangedRes   = newEXPIREATRes(true)
	EXPIREATResUnchangedRes = newEXPIREATRes(false)
)
View Source
var (
	EXPIRETIMEResNilRes = newEXPIRETIMERes(0)
	EXPIRETIMEResNegOne = newEXPIRETIMERes(-1)
	EXPIRETIMEResNegTwo = newEXPIRETIMERes(-2)
)
View Source
var (
	FLUSHDBResOKRes  = newFLUSHDBRes()
	FLUSHDBResNilRes = newFLUSHDBRes()
)
View Source
var (
	HANDSHAKEResNilRes = newHANDSHAKERes()
	HANDSHAKEResOKRes  = newHANDSHAKERes()
)
View Source
var (
	SETResNilRes = newSETRes()
	SETResOKRes  = newSETRes()
)
View Source
var (
	TTLResNilRes      = newTTLRes(0)
	TTLResNoExpiryRes = newTTLRes(-1)
	TTLResNotFoundRes = newTTLRes(-2)
)
View Source
var (
	UNWATCHResNilRes = newUNWATCHRes()
	UNWATCHResOKRes  = newUNWATCHRes()
)
View Source
var (
	ZCOUNTResNilRes = newZCOUNTRes(0)
	ZCOUNTRes0      = newZCOUNTRes(0)
)
View Source
var (
	ZREMResNilRes = newZREMRes(0)
	ZREMRes0      = newZREMRes(0)
)
View Source
var (
	DECRBYResNilRes = newDECRBYRes(0)
)
View Source
var (
	DECRResNilRes = newDECRRes(0)
)
View Source
var (
	DELResNilRes = newDELRes(0)
)
View Source
var (
	GETDELResNilRes = newGETDELRes(nil)
)
View Source
var (
	GETEXResNilRes = newGETEXRes(nil)
)
View Source
var (
	GETResNilRes = newGETRes(nil)
)
View Source
var (
	GETSETResNilRes = newGETSETRes(nil)
)
View Source
var (
	GETWATCHResNilRes = newGETWATCHRes()
)
View Source
var (
	HGETALLResNilRes = newHGETALLRes([]*wire.HElement{})
)
View Source
var (
	HGETALLWATCHResNilRes = newHGETALLWATCHRes()
)
View Source
var (
	HGETResNilRes = newHGETRes("")
)
View Source
var (
	HGETWATCHResNilRes = newHGETWATCHRes()
)
View Source
var (
	HSETResNilRes = newHSETRes(0)
)
View Source
var (
	INCRBYResNilRes = newINCRBYRes(0)
)
View Source
var (
	INCRResNilRes = newINCRRes(0)
)
View Source
var (
	KEYSResNilRes = newKEYSRes([]string{})
)
View Source
var PINGResNilRes = newPINGRes("")
View Source
var (
	TYPEResNilRes = newTYPERes("none")
)
View Source
var (
	ZADDResNilRes = newZADDRes(0)
)
View Source
var (
	ZCARDResNilRes = newZCARDRes(0)
)
View Source
var (
	ZCARDWATCHResNilRes = newZCARDWATCHRes()
)
View Source
var (
	ZCOUNTWATCHResNilRes = newZCOUNTWATCHRes()
)
View Source
var (
	ZPOPMAXResNilRes = newZPOPMAXRes([]*wire.ZElement{})
)
View Source
var (
	ZPOPMINResNilRes = newZPOPMINRes([]*wire.ZElement{})
)
View Source
var (
	ZRANGEResNilRes = newZRANGERes([]*wire.ZElement{})
)
View Source
var (
	ZRANGEWATCHResNilRes = newZRANGEWATCHRes()
)
View Source
var (
	ZRANKResNilRes = newZRANKRes(nil)
)
View Source
var (
	ZRANKWATCHResNilRes = newZRANKWATCHRes()
)

Functions

func CreateObjectFromValue added in v1.0.5

func CreateObjectFromValue(s *dstore.Store, value string, expiryMs int64) *object.Obj

func Total

func Total() int

Types

type Cmd

type Cmd struct {
	C        *wire.Command
	IsReplay bool
	ClientID string
	Mode     string
	Meta     *CommandMeta
}

func (*Cmd) Execute

func (c *Cmd) Execute(sm *shardmanager.ShardManager) (*CmdRes, error)

func (*Cmd) Fingerprint

func (c *Cmd) Fingerprint() uint64

func (*Cmd) Key

func (c *Cmd) Key() string

func (*Cmd) String

func (c *Cmd) String() string

type CmdRegistry

type CmdRegistry struct {
	CommandMetas map[string]*CommandMeta
}
var CommandRegistry CmdRegistry = CmdRegistry{
	CommandMetas: map[string]*CommandMeta{},
}

func (*CmdRegistry) AddCommand

func (r *CmdRegistry) AddCommand(cmd *CommandMeta)

type CmdRes

type CmdRes struct {
	Rs       *wire.Result
	ClientID string
}

type CommandMeta

type CommandMeta struct {
	Name      string
	HelpShort string
	Syntax    string
	Examples  string
	HelpLong  string
	Eval      func(c *Cmd, s *store.Store) (*CmdRes, error)
	Execute   func(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, error)
}

type DiceDBCmd

type DiceDBCmd struct {
	// Cmd represents the command to execute (e.g., "SET", "GET", "DEL").
	// This is the main command keyword that specifies the action to perform
	// in DiceDB. For example:
	// - "SET": To store a value.
	// - "GET": To retrieve a value.
	// - "DEL": To delete a value.
	// - "EXPIRE": To set a time-to-live for a key.
	Cmd string

	// Args holds any additional parameters required by the command.
	// For example:
	// - If Cmd is "SET", Args might contain ["key", "value"].
	// - If Cmd is "EXPIRE", Args might contain ["key", "seconds"].
	// This slice allows flexible support for commands with variable arguments.
	Args []string

	// InternalObjs is a pointer to list of InternalObjs, representing an optional data structure
	// associated with the command. This contains pointer to the underlying simple
	// types such as int, string or even complex types
	// like hashes, sets, or sorted sets, which are stored and manipulated as objects.
	// WARN: This parameter should be used with caution
	InternalObjs []*object.InternalObj
}

DiceDBCmd represents a command structure to be executed within a DiceDB system. This struct emulates the way DiceDB commands are structured, including the command itself, additional arguments, and an optional object to store or manipulate.

func (*DiceDBCmd) Fingerprint

func (cmd *DiceDBCmd) Fingerprint() uint32

GetFingerprint returns a 32-bit fingerprint of the command and its arguments.

func (*DiceDBCmd) Key

func (cmd *DiceDBCmd) Key() string

Key Returns the key which the command operates on.

TODO: This is a naive implementation which assumes that the first argument is the key. This is not true for all commands, however, for now this is only used by the watch manager, which as of now only supports a small subset of commands (all of which fit this implementation).

func (*DiceDBCmd) Repr

func (cmd *DiceDBCmd) Repr() string

Repr returns a string representation of the command.

type DiceDBCmds

type DiceDBCmds struct {
	Cmds      []*DiceDBCmd
	RequestID uint32
}

type SSMap added in v1.0.4

type SSMap map[string]string

func (SSMap) Get added in v1.0.4

func (h SSMap) Get(k string) (string, bool)

Get returns the value for the key in the SSMap. Returns false if the key does not exist. Returns the value if the key exists.

func (SSMap) Set added in v1.0.4

func (h SSMap) Set(k, v string) (string, bool)

Set sets the value v for the key k in the SSMap. Returns the old value if the key exists. The bool return value indicates if the key was already present in the SSMap.

Jump to

Keyboard shortcuts

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