rq

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultKeyDelimiter is used to join tokens for key parameters in default.
	DefaultKeyDelimiter = ":"

	// DefaultKeyPrefixDelimiter is used to join key and prefix in default.
	DefaultKeyPrefixDelimiter = "/"
)

Functions

This section is empty.

Types

type Command

type Command struct {
	Name string
	Args []interface{}
}

Command contains a redis command name and args.

func (*Command) String

func (c *Command) String() string

type CommandType

type CommandType int

CommandType represents operation types of a query.

const (
	CommandList CommandType = iota
	CommandCount
)

Command types

type Error

type Error interface {
	error
	Query() *Query
}

Error represents errors caused by query building.

type Modifier

type Modifier func(*Query)

Modifier modifies a Query object.

func Eq

func Eq(v interface{}) Modifier

Eq specifies a value range with `=` for scores of a query.

func Gt

func Gt(v interface{}) Modifier

Gt specifies a value range with `>` for scores of a query.

func GtEq

func GtEq(v interface{}) Modifier

GtEq specifies a value range with `>=` for scores of a query.

func Key

func Key(tokens ...interface{}) Modifier

Key specifies a key parameter of a query.

func KeyPrefix

func KeyPrefix(prefix string) Modifier

KeyPrefix specifies a key prefix of a query.

func Limit

func Limit(v int) Modifier

Limit specifies returned values count of a query.

func Lt

func Lt(v interface{}) Modifier

Lt specifies a value range with `<` for scores of a query.

func LtEq

func LtEq(v interface{}) Modifier

LtEq specifies a value range with `<=` for scores of a query.

func Offset

func Offset(v int) Modifier

Offset specifies returned values offset of a query.

func Reverse

func Reverse() Modifier

Reverse specifies returned values order of a query.

type Query

type Query struct {
	Type    CommandType
	Key     QueryKey
	Min     interface{}
	Max     interface{}
	Limit   int
	Offset  int
	Reverse bool
}

Query contains parameters to build a redis command.

func Count

func Count(mods ...Modifier) *Query

Count creates a Query object for count operation.

func List

func List(mods ...Modifier) *Query

List creates a Query object for list operation.

func (*Query) Build

func (q *Query) Build() (*Command, error)

Build decide a redis command and args from query parameters.

type QueryKey

type QueryKey struct {
	Delimiter       string
	Tokens          []interface{}
	Prefix          string
	PrefixDelimiter string
}

QueryKey contains parameters to build a key for a redis command.

func (*QueryKey) Build

func (q *QueryKey) Build() (string, error)

Build creates a key string.

Jump to

Keyboard shortcuts

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