Documentation
¶
Overview ¶
Package redis use gofame-gredis implement common-usage redis functions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Redis Client wrappers
Example (Publish) ¶
package main import ( "sync" "github.com/lovelacelee/clsgo/v1/redis" ) var workGroup sync.WaitGroup const messageCount = 1000 func main() { c := redis.New("default") defer c.Close() for i := 0; i < messageCount; i++ { c.Do("PUBLISH", "channel", "test") } workGroup.Done() }
Output:
func New ¶
Name valid in default/cache, initialized with config.yaml, See order for more https://www.redis.net.cn/order/
Example ¶
package main import ( "github.com/lovelacelee/clsgo/v1/redis" ) func main() { c := redis.New("default") defer c.Close() }
Output:
func (*Client) Do ¶
Example ¶
package main import ( "fmt" "github.com/lovelacelee/clsgo/pkg/version" "github.com/lovelacelee/clsgo/v1/redis" ) func main() { c := redis.New("default") defer c.Close() c.Do("SET", "clsgo", version.Version) rv, _ := c.Do("GET", "clsgo") fmt.Println(rv.String()) }
Output:
func (*Client) Subscribe ¶
Redis subscribe, return a go chan for receive message notification
Example ¶
package main import ( "fmt" "sync" "github.com/lovelacelee/clsgo/v1/redis" ) var workGroup sync.WaitGroup const messageCount = 1000 func main() { c := redis.New("default") defer c.Close() notify := c.Subscribe("channel") var payload string for i := 0; i < messageCount; i++ { resp := <-notify channelRes := struct { Channel string Pattern string Payload string PayloadSlice string }{} resp.Struct(&channelRes) payload = channelRes.Payload } fmt.Printf("Receive %v %v times\n", payload, messageCount) workGroup.Done() // Output // v0.0.9 // Receive test 1000 times }
Output:
Click to show internal directories.
Click to hide internal directories.