Categorygithub.com/aacfactory/fns-contrib/databases/redis
package
1.3.0
Repository: https://github.com/aacfactory/fns-contrib.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

REDIS

One redis service for fns.

Note

redis version must be greater than 7.0.5

Install

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

Usage

Config

Example

redis:
  initAddress:
    - "ip:port"
  username: ""
  password: ""

Note: see rueidis for more details

Deploy

app.Deply(redis.New())

Use service client

// set
_, setErr := redis.Do(ctx, redis.Set("some", time.Now().Format(time.RFC3339)).Ex(10*time.Second))
if setErr != nil {
    return
}

// get
r, getErr := redis.Do(ctx, redis.Get("some"))
if getErr != nil {
    // 
    return
}
if r.IsNil() {  
	// 
	return
}
s, sErr := r.AsString()
if sErr != nil {
	return
}

Cluster

Register cluster

imports (
	_ "github.com/aacfactory/fns-contrib/databases/redis/clusters"
)

Setup config

cluster:
  name: "redis"
  option:
    initAddress:
      - "ip:port"
    username: ""
    password: ""
    keepAlive:
      ttl: "60s"
      interval: "10s"
    barrier:
      ttl: "5s"

Note: it will use it owned barrier steadof common cluster barrier.