redis

package module
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: Apache-2.0 Imports: 11 Imported by: 4

README

REDIS

One redis service for fns

Install

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

Usage

Config
  • Standalone type
    • masterSlaverMode = false
    • addr size is one
  • Master slaver type
    • masterSlaverMode = true
    • first of addr is master, afters are slavers
  • Cluster type
    • masterSlaverMode = false
    • all in addr is members

Example

redis:
  masterSlaverMode: false
  network: "tcp"
  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 Exist added in v0.12.1

func Exist(ctx context.Context, key string) (ok bool, err errors.CodeError)

func Expire

func Expire(ctx context.Context, key string, expiration time.Duration) (ok bool, err errors.CodeError)

func Incr

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

func Lock

func Lock(ctx context.Context, key string, expiration time.Duration) (err errors.CodeError)

func Persist

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

func Remove

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

func SAdd added in v0.12.1

func SAdd(ctx context.Context, key string, members ...interface{}) (err errors.CodeError)

func SMembers added in v0.12.1

func SMembers(ctx context.Context, key string) (members []string, err errors.CodeError)

func SRem added in v0.12.1

func SRem(ctx context.Context, key string, members ...interface{}) (err errors.CodeError)

func Service

func Service() service.Service

func Set

func Set(ctx context.Context, key string, value string, expiration time.Duration) (err errors.CodeError)

func Unlock

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

Types

type Client

type Client interface {
	Do(ctx context.Context, args ...interface{}) *rds.Cmd
	Writer() (cmd rds.Cmdable)
	Reader() (cmd rds.Cmdable)
	Close() (err error)
}

type Command added in v0.12.1

type Command struct {
	Name   string `json:"name"`
	Params Params `json:"params"`
}

type Params added in v0.12.1

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

func (*Params) Append added in v0.12.1

func (args *Params) Append(v interface{}) (err errors.CodeError)

func (*Params) MarshalJSON added in v0.12.1

func (args *Params) MarshalJSON() (p []byte, err error)

func (*Params) UnmarshalJSON added in v0.12.1

func (args *Params) UnmarshalJSON(p []byte) (err error)

type Result added in v0.12.1

type Result struct {
	Exist bool   `json:"exist"`
	Value []byte `json:"value"`
}

func DoCommand added in v0.12.1

func DoCommand(ctx context.Context, command Command) (result *Result, err errors.CodeError)

func Get

func Get(ctx context.Context, key string) (result *Result, err errors.CodeError)

func GetSet added in v0.6.0

func GetSet(ctx context.Context, key string, value string, expiration time.Duration) (result *Result, err errors.CodeError)

func (*Result) DecodeJsonValueTo added in v0.12.1

func (r *Result) DecodeJsonValueTo(v interface{}) (err errors.CodeError)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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