redis

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 10 Imported by: 4

README

REDIS

One redis service for fns

Install

go get github.com/aacfactory/fns-contrib/databases/redis

Usage

Config
  • Standalone type
    • addr size is one
  • Cluster type
    • all in addr is members

Example

redis:
  db:
    addr: 
      - "ip:port"
    username: ""
    password: ""
    db: 0
    poolSize: 0
Deploy
app.Deply(redis.Service())
Use service client
// get
result, err := redis.Get(ctx, key)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decr

func Decr(ctx context.Context, key string) (v int64, err errors.CodeError)

func DecrBy added in v1.0.0

func DecrBy(ctx context.Context, param DecrByParam) (v int64, err errors.CodeError)

func Del added in v1.0.0

func Del(ctx context.Context, keys []string) (err errors.CodeError)

func Discard added in v1.0.0

func Discard(ctx context.Context) (err errors.CodeError)

func Exists added in v1.0.0

func Exists(ctx context.Context, key string) (has bool, err errors.CodeError)

func Expire

func Expire(ctx context.Context, param ExpireParam) (err errors.CodeError)

func GeoAdd added in v1.0.6

func GeoAdd(ctx context.Context, param GeoAddParam) (err errors.CodeError)

func GeoDist added in v1.0.6

func GeoDist(ctx context.Context, param GeoDistParam) (dist float64, err errors.CodeError)

func GeoHash added in v1.0.6

func GeoHash(ctx context.Context, param GeoDistParam) (n []string, err errors.CodeError)

func GeoSearchStore added in v1.0.6

func GeoSearchStore(ctx context.Context, param GeoSearchStoreParam) (n int64, err errors.CodeError)

func HDel added in v1.0.6

func HDel(ctx context.Context, param HDelParam) (err errors.CodeError)

func HExist added in v1.0.6

func HExist(ctx context.Context, param HExistParam) (ok bool, err errors.CodeError)

func HGetALL added in v1.0.6

func HGetALL(ctx context.Context, param string) (values map[string]string, err errors.CodeError)

func HSet added in v1.0.6

func HSet(ctx context.Context, param HSetParam) (err errors.CodeError)

func Incr

func Incr(ctx context.Context, key string) (v int64, err errors.CodeError)

func IncrBy added in v1.0.0

func IncrBy(ctx context.Context, param IncrByParam) (v int64, err errors.CodeError)

func Keys added in v1.0.0

func Keys(ctx context.Context, pattern string) (values []string, err errors.CodeError)

func MGet added in v1.0.0

func MGet(ctx context.Context, keys []string) (v map[string]string, err errors.CodeError)

func MSet added in v1.0.0

func MSet(ctx context.Context, param MSetParam) (err errors.CodeError)

func Persist

func Persist(ctx context.Context, key string) (err errors.CodeError)

func Pipeline added in v1.0.0

func Pipeline(ctx context.Context, tx bool) (err errors.CodeError)

func Service

func Service(databases ...string) service.Service

func Set

func Set(ctx context.Context, param SetParam) (err errors.CodeError)

func SetEx added in v1.0.0

func SetEx(ctx context.Context, param SetParam) (err errors.CodeError)

func SetNx added in v1.0.0

func SetNx(ctx context.Context, param SetParam) (err errors.CodeError)

func Sort added in v1.0.0

func Sort(ctx context.Context, param SortParam) (v []string, err errors.CodeError)

func WithOptions added in v1.0.0

func WithOptions(ctx context.Context, options ...ProxyOption) context.Context

func ZAdd

func ZAdd(ctx context.Context, param ZAddParam) (v int64, err errors.CodeError)

func ZCard

func ZCard(ctx context.Context, param ZCardParam) (v int64, err errors.CodeError)

func ZCount added in v1.0.0

func ZCount(ctx context.Context, param ZCountParam) (v int64, err errors.CodeError)

func ZRange

func ZRange(ctx context.Context, param ZRangeParam) (v []string, err errors.CodeError)

func ZRangeByScore added in v1.0.0

func ZRangeByScore(ctx context.Context, param ZRangeByScoreParam) (v []string, err errors.CodeError)

func ZRem

func ZRem(ctx context.Context, param ZRemParam) (v int64, err errors.CodeError)

func ZRemRangeByRank added in v1.0.0

func ZRemRangeByRank(ctx context.Context, param ZRemByRangeParam) (v int64, err errors.CodeError)

func ZRemRangeByScore added in v1.0.0

func ZRemRangeByScore(ctx context.Context, param ZRemByScoreParam) (v int64, err errors.CodeError)

Types

type DecrByParam added in v1.0.0

type DecrByParam struct {
	Key   string `json:"key"`
	Value int64  `json:"value"`
}

type ExecResult added in v1.0.0

type ExecResult struct {
	Finished bool              `json:"finished"`
	Cmders   []ExecResultCmder `json:"cmders"`
}

type ExecResultCmder added in v1.0.0

type ExecResultCmder struct {
	Name  string `json:"name"`
	Error string `json:"error"`
}

func Exec added in v1.0.0

func Exec(ctx context.Context) (v []ExecResultCmder, err errors.CodeError)

type ExpireParam

type ExpireParam struct {
	Key        string        `json:"key"`
	Expiration time.Duration `json:"expiration"`
}

type GeoAddParam added in v1.0.6

type GeoAddParam struct {
	Key       string         `json:"key"`
	Locations []*GeoLocation `json:"locations"`
}

type GeoDistParam added in v1.0.6

type GeoDistParam struct {
	Key        string `json:"key"`
	SourceName string `json:"sourceName"`
	TargetName string `json:"targetName"`
	Unit       string `json:"unit"`
}

type GeoHashParam added in v1.0.6

type GeoHashParam struct {
	Key   string   `json:"key"`
	Names []string `json:"names"`
}

type GeoLocation added in v1.0.6

type GeoLocation struct {
	Name      string  `json:"name"`
	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`
	Dist      float64 `json:"dist"`
	GeoHash   int64   `json:"geoHash"`
}

func GeoSearch added in v1.0.6

func GeoSearch(ctx context.Context, param GeoSearchParam) (n []*GeoLocation, err errors.CodeError)

type GeoPosParam added in v1.0.6

type GeoPosParam struct {
	Key   string   `json:"key"`
	Names []string `json:"names"`
}

type GeoPosition added in v1.0.6

type GeoPosition struct {
	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`
}

func GeoPos added in v1.0.6

func GeoPos(ctx context.Context, param GeoPosParam) (n []*GeoPosition, err errors.CodeError)

type GeoSearchParam added in v1.0.6

type GeoSearchParam struct {
	Key   string                      `json:"key"`
	Query *rds.GeoSearchLocationQuery `json:"query"`
}

type GeoSearchStoreParam added in v1.0.6

type GeoSearchStoreParam struct {
	Key   string                   `json:"key"`
	Store string                   `json:"store"`
	Query *rds.GeoSearchStoreQuery `json:"query"`
}

type GetResult added in v0.6.0

type GetResult struct {
	Has   bool   `json:"has"`
	Value string `json:"value"`
}

func Get

func Get(ctx context.Context, key string) (v GetResult, err errors.CodeError)

func GetSet added in v0.6.0

func GetSet(ctx context.Context, param GetSetParam) (v GetResult, err errors.CodeError)

type GetSetParam added in v1.0.0

type GetSetParam struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type HDelParam added in v1.0.6

type HDelParam struct {
	Key    string   `json:"key"`
	Fields []string `json:"fields"`
}

type HExistParam added in v1.0.6

type HExistParam struct {
	Key   string `json:"key"`
	Field string `json:"field"`
}

type HGetParam added in v1.0.6

type HGetParam struct {
	Key   string `json:"key"`
	Field string `json:"field"`
}

type HGetResult added in v1.0.6

type HGetResult struct {
	Has   bool   `json:"has"`
	Value string `json:"value"`
}

func HGet added in v1.0.6

func HGet(ctx context.Context, param HGetParam) (v HGetResult, err errors.CodeError)

type HSetParam added in v1.0.6

type HSetParam struct {
	Key   string `json:"key"`
	Field string `json:"field"`
	Value string `json:"value"`
}

type IncrByParam added in v1.0.0

type IncrByParam struct {
	Key   string `json:"key"`
	Value int64  `json:"value"`
}

type KeyPair added in v1.0.0

type KeyPair struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type KeysParam added in v1.0.0

type KeysParam struct {
	Pattern string `json:"pattern"`
}

type KeysResult added in v1.0.0

type KeysResult struct {
	Values []string `json:"values"`
}

type MSetParam added in v1.0.0

type MSetParam []KeyPair

type PipelineParam added in v1.0.0

type PipelineParam struct {
	Tx bool `json:"tx"`
}

type ProxyOption added in v1.0.0

type ProxyOption func(*ProxyOptions)

func Database added in v1.0.0

func Database(name string) ProxyOption

type ProxyOptions added in v1.0.0

type ProxyOptions struct {
	// contains filtered or unexported fields
}

type ScanParam added in v1.0.0

type ScanParam struct {
	Cursor uint64 `json:"cursor"`
	Match  string `json:"match"`
	Count  int64  `json:"count"`
}

type ScanResult added in v1.0.0

type ScanResult struct {
	Keys []string `json:"keys"`
	Next uint64   `json:"next"`
}

func Scan added in v1.0.0

func Scan(ctx context.Context, param ScanParam) (r ScanResult, err errors.CodeError)

type SetParam

type SetParam struct {
	Key        string        `json:"key"`
	Value      string        `json:"value"`
	Expiration time.Duration `json:"expiration"`
}

type SortParam added in v1.0.0

type SortParam struct {
	Key    string   `json:"key"`
	By     string   `json:"by"`
	Offset int64    `json:"offset"`
	Count  int64    `json:"count"`
	Get    []string `json:"get"`
	Order  string   `json:"order"`
	Alpha  bool     `json:"alpha"`
}

type Z added in v1.0.0

type Z struct {
	Score float64 `json:"score"`
	Value string  `json:"value"`
}

type ZAddParam

type ZAddParam struct {
	Key    string `json:"key"`
	Values []Z    `json:"values"`
}

type ZCardParam added in v1.0.0

type ZCardParam struct {
	Key string `json:"key"`
}

type ZCountParam added in v1.0.0

type ZCountParam struct {
	Key string `json:"key"`
	Min string `json:"min"`
	Max string `json:"max"`
}

type ZRangeByScoreParam

type ZRangeByScoreParam struct {
	Key    string `json:"key"`
	Min    string `json:"min"`
	Max    string `json:"max"`
	Offset int64  `json:"offset"`
	Count  int64  `json:"count"`
}

type ZRangeParam

type ZRangeParam struct {
	Key   string `json:"key"`
	Start int64  `json:"start"`
	Stop  int64  `json:"stop"`
}

type ZRemByRangeParam added in v1.0.0

type ZRemByRangeParam struct {
	Key   string `json:"key"`
	Start int64  `json:"start"`
	Stop  int64  `json:"stop"`
}

type ZRemByScoreParam

type ZRemByScoreParam struct {
	Key string `json:"key"`
	Min string `json:"min"`
	Max string `json:"max"`
}

type ZRemParam

type ZRemParam struct {
	Key    string   `json:"key"`
	Values []string `json:"values"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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