command

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRange = 2<<29 - 1 // 512M
)
View Source
const (
	ModisVer = "0.1.0"
)

Variables

View Source
var (
	GitSha1  string
	GitDirty string
	BuildID  string
)

Functions

func Append

func Append(ctx *CmdContext) error

Append a value to a key

func Auth

func Auth(ctx *CmdContext) error

Auth verifies the client

func BitCount

func BitCount(ctx *CmdContext) error

BitCount counts the number of set bits (population counting) in a string.

func Call

func Call(ctx *CmdContext)

Call a command

func ClientHelp

func ClientHelp(ctx *CmdContext) error

func ClientInfo

func ClientInfo(ctx *CmdContext) error

func ClientList

func ClientList(ctx *CmdContext) error

func Decr

func Decr(ctx *CmdContext) error

Decr decrements the integer value of a key by one

func DecrBy

func DecrBy(ctx *CmdContext) error

DecrBy decrements the integer value of a key by the given number

func Delete

func Delete(ctx *CmdContext) error

Delete removes the specified keys. A key is ignored if it does not exist

func Echo

func Echo(ctx *CmdContext) error

Echo the given string

func Exists

func Exists(ctx *CmdContext) error

Exists returns if key exists

func Expire

func Expire(ctx *CmdContext) error

Expire sets a timeout on key

func ExpireAt

func ExpireAt(ctx *CmdContext) error

ExpireAt sets an absolute timestamp to expire on key

func Get

func Get(ctx *CmdContext) error

Get the value of key

func GetBit

func GetBit(ctx *CmdContext) error

GetBit gets the bit at offset in the string value stored at key.

func GetRange

func GetRange(ctx *CmdContext) error

GetRange increments the integer value of a keys by the given amount

func GetSet

func GetSet(ctx *CmdContext) error

GetSet sets the string value of a key and return its old value

func HDel

func HDel(ctx *CmdContext) error

HDel removes the specified fields from the hash stored at key

func HExists

func HExists(ctx *CmdContext) error

HExists returns if field is an existing field in the hash stored at key

func HGet

func HGet(ctx *CmdContext) error

HGet returns the value associated with field in the hash stored at key

func HGetAll

func HGetAll(ctx *CmdContext) error

HGetAll returns all fields and values of the hash stored at key

func HIncrBy

func HIncrBy(ctx *CmdContext) error

HIncrBy increments the number stored at field in the hash stored at key by increment

func HIncrByFloat

func HIncrByFloat(ctx *CmdContext) error

HIncrByFloat increment the specified field of a hash stored at key, and representing a floating point number, by the specified increment

func HKeys

func HKeys(ctx *CmdContext) error

HKeys returns all field names in the hash stored at key

func HLen

func HLen(ctx *CmdContext) error

HLen returns the number of fields contained in the hash stored at key

func HMGet

func HMGet(ctx *CmdContext) error

HMGet returns the values associated with the specified fields in the hash stored at key

func HSetNX

func HSetNX(ctx *CmdContext) error

HSetNX sets field in the hash stored at key to value, only if field does not yet exist

func HVals

func HVals(ctx *CmdContext) error

HVals returns all values in the hash stored at key

func HashCmdWithKey

func HashCmdWithKey(ctx *CmdContext) error

compat server

func Incr

func Incr(ctx *CmdContext) error

Incr increments the integer value of a key by one

func IncrBy

func IncrBy(ctx *CmdContext) error

IncrBy increments the integer value of a key by the given amount

func IncrByFloat

func IncrByFloat(ctx *CmdContext) error

IncrByFloat increments the float value of a key by the given amount

func Info

func Info(ctx *CmdContext) error

Info print modis info

func ListCmd

func ListCmd(ctx *CmdContext) error

func MGet

func MGet(ctx *CmdContext) error

MGet returns the values of all specified key

func MSet

func MSet(ctx *CmdContext) error

MSet sets the given keys to their respective values

func Monitor

func Monitor(ctx *CmdContext) error

func PExpire

func PExpire(ctx *CmdContext) error

PExpire works exactly like expire but the time to live of the key is specified in milliseconds instead of seconds

func PExpireAt

func PExpireAt(ctx *CmdContext) error

PExpireAt has the same effect and semantic as expireAt, but the Unix time at which the key will expire is specified in milliseconds instead of seconds

func PSetEx

func PSetEx(ctx *CmdContext) error

PSetEx sets the value and expiration in milliseconds of a key

func PTTL

func PTTL(ctx *CmdContext) error

PTTL likes TTL this command returns the remaining time to live of a key that has an expire set, with the sole difference that TTL returns the amount of remaining time in seconds while PTTL returns it in milliseconds

func Persist

func Persist(ctx *CmdContext) error

Persist removes the existing timeout on key, turning the key from volatile to persistent

func Ping

func Ping(ctx *CmdContext) error

Ping the server

func Quit

func Quit(ctx *CmdContext) error

Quit asks the server to close the connection

func SAdd

func SAdd(ctx *CmdContext) error

SAdd adds the specified members to the set stored at key

func SCard

func SCard(ctx *CmdContext) error

SCard returns the set cardinality (number of elements) of the set stored at key

func SDiff

func SDiff(ctx *CmdContext) error

SDiff returns the members of the set resulting from the difference between the first set and all the successive sets.

func SDiffServer

func SDiffServer(ctx *CmdContext) error

SDiff returns the members of the set resulting from the difference between the first set and all the successive sets.

func SDiffStore

func SDiffStore(ctx *CmdContext) error

SDiffStore stores the difference set between the given sets in the specified set.

func SInter

func SInter(ctx *CmdContext) error

SInter returns the members of the set resulting from the intersection of all the given sets.

func SInterStore

func SInterStore(ctx *CmdContext) error

SInterStore stores the members of the set resulting from the intersection of all the given sets.

func SIsmember

func SIsmember(ctx *CmdContext) error

SIsmember returns if member is a member of the set stored at key

func SMembers

func SMembers(ctx *CmdContext) error

SMembers returns all the members of the set value stored at key

func SMove

func SMove(ctx *CmdContext) error

SMove movies member from the set at source to the set at destination

func SPop

func SPop(ctx *CmdContext) error

SPop removes and returns one or more random elements from the set value storage at key

func SRandMember

func SRandMember(ctx *CmdContext) error

SRandMember returns random members of the set

func SRem

func SRem(ctx *CmdContext) error

SRem removes the specified members from the set stored at key

func SUnion

func SUnion(ctx *CmdContext) error

SUnion returns the members of the set resulting from the union of all the given sets.

func SUnionStore

func SUnionStore(ctx *CmdContext) error

SUnionStore stores the members of the set resulting from the union of all the given sets.

func Select

func Select(ctx *CmdContext) error

Select the logical database

func Set

func Set(ctx *CmdContext) error

Set key to hold the string value

func SetBit

func SetBit(ctx *CmdContext) error

SetBit sets or clears the bit at offset in the string value stored at key.

func SetEx

func SetEx(ctx *CmdContext) error

SetEx sets the value and expiration of a key KEY_NAME TIMEOUT VALUE

func SetNx

func SetNx(ctx *CmdContext) error

SetNx sets the value of a key ,only if the key does not exist

func SetRange

func SetRange(ctx *CmdContext) error

SetRange overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.

func Strlen

func Strlen(ctx *CmdContext) error

Strlen returns the length of the string value stored at key

func SwapDB

func SwapDB(ctx *CmdContext) error

SwapDB swaps two modis databases

func TTL

func TTL(ctx *CmdContext) error

TTL returns the remaining time to live of a key that has a timeout

func TempNotSupport

func TempNotSupport(ctx *CmdContext) error

func Type

func Type(ctx *CmdContext) error

Type returns the string representation of the type of the value stored at key

func ZIncrBy

func ZIncrBy(ctx *CmdContext) error

func ZSetCmdWithKey

func ZSetCmdWithKey(ctx *CmdContext) error

func ZSetCmdWithKeyMember

func ZSetCmdWithKeyMember(ctx *CmdContext) error

Types

type CmdContext

type CmdContext struct {
	Name       string   // command name,e.g. "client"
	FullName   string   // command name,e.g. "client|info"
	Args       [][]byte // command's args,e.g. ["key", "value"]
	OutContent string   // command's output
	TraceID    string
	// request without decoding, e.g. *2\r\n$3\r\nGET\r\n$3\r\nkey\r\n
	PlainReq []byte
	CodecCtx *conncontext.CodecContext
	ServCtx  *conncontext.ServerContext
	context.Context
}

CmdContext is the runtime context of a command

func NewCmdContext

func NewCmdContext(name string, args [][]byte, traceID string, plainReq []byte,
	codecCtx *conncontext.CodecContext, servCtx *conncontext.ServerContext) *CmdContext

NewCmdContext create a new command context

type CmdFlag

type CmdFlag int
const (
	CmdNone  CmdFlag = 0
	CmdAdmin CmdFlag = 1 << iota
	CmdSkipMonitor
)

type CmdInfo

type CmdInfo struct {
	Cmd Command
	// number of arguments, it is possible to use -N to say >= N
	Arity int
	Flag  CmdFlag
	Stats CmdStats
}

CmdInfo describes a command with constraints

type CmdStats

type CmdStats struct {
	Calls    int64
	MicroSec int64
}

CmdStat describes command statistics

func (*CmdStats) GetUsecPerCall

func (cs *CmdStats) GetUsecPerCall() float64

type Command

type Command func(ctx *CmdContext) error

Command is a modis command implementation

type DBInfo

type DBInfo struct {
	Keys    int64
	Expires int64
}

Jump to

Keyboard shortcuts

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