forked from joomcode/redispipe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
45 lines (37 loc) · 1.13 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Package redis contains common parts for other packages.
- main interfaces visible to user (Sender, Scanner, ScanOpts)
- wrappers for synchronous interface over Sender (Sync, SyncCtx)
and chan-based-future interface (ChanFutured)
- request writing,
- response parsing,
- root errorx namespace and common error types.
Usually you get Sender from redisconn.Connect or rediscluster.NewCluster, then wrap with Sync or SyncCtx, and use their
sync methods without any locking:
sender, err := redisconn.Connect(ctx, "127.0.0.1:6379", redisconn.Opts{})
sync := redis.Sync{sender}
go func() {
res := sync.Do("GET", "x")
if err := redis.AsError(res); err != nil {
log.Println("failed", err)
}
log.Println("found x", res)
}()
go func() {
results := sync.SendMany([]redis.Request{
redis.Req("GET", "k1"),
redis.Req("Incr", "k2"),
redis.Req("HMGET, "h1", "hk1", "hk2"),
})
if err := redis.AsError(results[0]); err != nil {
log.Println("failed", err)
}
if results[0] == nil {
log.Println("not found")
} else {
log.Println("k1: ", results[0])
}
}()
See more documentation in root redispipe package.
*/
package redis