Version: v2.0.0+incompatible Latest Latest

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

Go to latest
Published: Jan 27, 2019 License: MIT Imports: 2 Imported by: 0




View Source
const (
	// ClientInactive signifies that the client is inactive in Handler
	ClientInactive = "inactive"

	// PopArrLast gives index of the last element for JSONArrPop
	PopArrLast = -1

	// DebugMemorySubcommand provide the corresponding MEMORY sub commands for JSONDebug
	DebugMemorySubcommand DebugSubCommand = "MEMORY"

	// DebugHelpSubcommand provide the corresponding HELP sub commands for JSONDebug
	DebugHelpSubcommand DebugSubCommand = "HELP"

	// DebugHelpOutput is the output of command JSON.Debug HELP <obj> [path]
	DebugHelpOutput = "MEMORY <key> [path] - reports memory usage\nHELP                - this message"

	// ReJSON Commands
	ReJSONCommandSET       ReJSONCommandID = 0
	ReJSONCommandGET       ReJSONCommandID = 1
	ReJSONCommandDEL       ReJSONCommandID = 2
	ReJSONCommandMGET      ReJSONCommandID = 3
	ReJSONCommandTYPE      ReJSONCommandID = 4
	ReJSONCommandSTRLEN    ReJSONCommandID = 8
	ReJSONCommandARRLEN    ReJSONCommandID = 10
	ReJSONCommandARRPOP    ReJSONCommandID = 11
	ReJSONCommandARRINDEX  ReJSONCommandID = 12
	ReJSONCommandARRTRIM   ReJSONCommandID = 13
	ReJSONCommandOBJKEYS   ReJSONCommandID = 15
	ReJSONCommandOBJLEN    ReJSONCommandID = 16
	ReJSONCommandDEBUG     ReJSONCommandID = 17
	ReJSONCommandFORGET    ReJSONCommandID = 18
	ReJSONCommandRESP      ReJSONCommandID = 19

	// JSONSET command Options
	SetOptionNX SetOption = "NX"
	SetOptionXX SetOption = "XX"


View Source
var (
	ErrInternal          = fmt.Errorf("error: internal client error")
	ErrNoClientSet       = fmt.Errorf("no redis client is set")
	ErrTooManyOptionals  = fmt.Errorf("error: too many optional arguments")
	ErrNeedAtleastOneArg = fmt.Errorf("error: need atleast one argument in varing field")

	// GoRedis specific Nil error
	ErrGoRedisNil = fmt.Errorf("redis: nil")

Generic and Constant Errors to be returned to client to maintain stability

View Source
var (
	GETOptionSPACE    = GetOption{"SPACE", " "}
	GETOptionINDENT   = GetOption{"INDENT", "\t"}
	GETOptionNEWLINE  = GetOption{"NEWLINE", "\n"}
	GETOptionNOESCAPE = GetOption{"NOESCAPE", ""}

JSONGet Command Options


func BytesToString

func BytesToString(lst interface{}) (str string)

BytesToString converts each byte in a byte slice into character, else panic out

func CommandBuilder

func CommandBuilder(commandNameIn ReJSONCommandID, argsIn ...interface{}) (commandNameOut string, argsOut []interface{}, err error)

CommandBuilder is used to build a command that can be used directly to build REJSON commands

This is especially useful if you do not need to client's `Do()` method and instead need to use the JSON.* commands in the MUTLI/EXEC scenario along with some other operations like


func StringToBytes

func StringToBytes(lst interface{}) (by []byte)

StringToBytes converts each character of the string slice into byte, else panic out


type CommandBuilderFunc

type CommandBuilderFunc func(argsIn ...interface{}) (argsOut []interface{}, err error)

CommandBuilderFunc uses for the simplicity of the corresponding ReJSON module command builders

type DebugSubCommand

type DebugSubCommand string

DebugSubCommand provides the abstract sub-commands for the JSON.DEBUG command

type GetOption

type GetOption struct {
	Arg string
	// contains filtered or unexported fields

GetOption implements ReJSONOption for JSON.GET Method Get Options:

	* INDENT 	(with default set to a tab, '\t')
	* NEWLINE	(with default set to a new line, '\n')
 * SPACE		(with default set to a space, ' ')
 * NOESCAPE  (a boolean type option)

func (GetOption) MethodID

func (g GetOption) MethodID() ReJSONCommandID

MethodID returns the name of the method i.e. JSON.GET

func (GetOption) SetValue

func (g GetOption) SetValue(arg string)

func (GetOption) Value

func (g GetOption) Value() []interface{}

Value returns the value of the option being used

type ReJSONCommandID

type ReJSONCommandID int32

ReJSONCommandID marks a particular unique id to all the ReJSON commands to ensure proper type safety and help reducing typos in using them.

func (ReJSONCommandID) Details

Details returns the details of the CommandId like its command function and name

func (ReJSONCommandID) TypeSafety

func (r ReJSONCommandID) TypeSafety() error

TypeSafety checks the validity of the command id

func (ReJSONCommandID) Value

func (r ReJSONCommandID) Value() int32

Value returns integral value of the ReJSON Command ID

type ReJSONOption

type ReJSONOption interface {
	// Value returns the value of the option being used
	Value() []interface{}

	// MethodID returns the ID of the ReJSON Function defined in ReJSONCommands
	// whose options are begins implemented
	MethodID() ReJSONCommandID

ReJSONOption provides methods for the options used by various ReJSON commands It also abstracts options from the required parameters of the commands



type SetOption

type SetOption string

SetOption implements ReJSONOption for JSON.SET Method Set Options:

* NX or XX

func (SetOption) MethodID

func (g SetOption) MethodID() ReJSONCommandID

MethodID returns the name of the method i.e. JSON.SET

func (SetOption) Value

func (g SetOption) Value() []interface{}

Value returns the value of the option being used

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL