command

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadMode    = "r"
	WriteMode   = "w"
	PersistMode = "+"
)

Variables

View Source
var (
	// ErrMissingKeyArg is thrown when the client did not send the key argument for the command
	ErrMissingKeyArg = errors.New("missing key argument")

	// ErrMissingValueArg is thrown when the client did not send the value argument for the command
	ErrMissingValueArg = errors.New("missing value argument")

	// ErrMissingKeyValueArg is thrown when the client did not send both the key and value arguments for the command
	ErrMissingKeyValueArg = errors.New("missing key/value arguments")

	// ErrInvalidArgLength is thrown when the client provides missing arguments or does not satisfy the amount of required args for the command
	ErrInvalidArgLength = errors.New("missing arguments")

	// ErrCommandDoesNotExist is thrown when the command does not exists in the command package
	ErrCommandDoesNotExist = errors.New("command does not exists")

	// ErrInternalError is thrown when an error on the server side has occured
	ErrInternalError = errors.New("internal error")
)

Functions

This section is empty.

Types

type Command

type Command interface {
	String() string
	Execute(args []string) []byte
}

Command is the set of methods for a commmand

func New added in v0.4.0

func New(db storage.Store, stats *stats.Stats, cmd Op) Command

New constructs the given command operation

type Op added in v0.4.3

type Op int

Op represents the command operation code

const (
	// SET inserts a new entry into the database
	SET Op = iota
	// SETEX inserts a new expirable entry into the database
	SETEX
	// GET returns the data in the database with the matching key
	GET
	// DEL remove an entry in the database with the matching key
	DEL
	// KEYS displays all the saved keys in the database
	KEYS
	// FLUSHALL delete all keys
	FLUSHALL
	// INFO displays the current status of the server (memory allocs, connected clients, uptime, etc.)
	INFO
	// Pings the server
	PING
)

func (Op) Args added in v0.20.3

func (c Op) Args() string

Args is the command operation required arguments

func (Op) Bytes added in v1.0.0

func (c Op) Bytes() []byte

func (Op) Description added in v0.20.3

func (c Op) Description() string

Description is the command operation description

func (Op) Opts added in v1.0.0

func (c Op) Opts() string

Opts is the command operation options which can be Read (r), Write (w) and Persist (+)

func (Op) String added in v0.4.3

func (c Op) String() string

type Options added in v1.0.0

type Options struct {
	Op      Op
	Full    string
	Command string
	Args    []string
	Mode    []string
}

func Parse added in v1.0.0

func Parse(input string) (Options, error)

Jump to

Keyboard shortcuts

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