forked from mirror/redis
Update readme.
This commit is contained in:
parent
e40a6041e1
commit
1f7cc3fea5
42
README.md
42
README.md
|
@ -5,7 +5,7 @@ Redis client for Golang.
|
||||||
|
|
||||||
Supports:
|
Supports:
|
||||||
|
|
||||||
- Redis 2.6 commands except QUIT command.
|
- Redis 2.6 commands except QUIT, MONITOR, SLOWLOG and SYNC.
|
||||||
- Pub/sub.
|
- Pub/sub.
|
||||||
- Transactions.
|
- Transactions.
|
||||||
- Pipelining.
|
- Pipelining.
|
||||||
|
@ -50,13 +50,13 @@ Example 2:
|
||||||
|
|
||||||
initConn := func(client *redis.Client) error {
|
initConn := func(client *redis.Client) error {
|
||||||
auth := client.Auth("key")
|
auth := client.Auth("key")
|
||||||
if auth.Err() != nil {
|
if err := auth.Err(); err != nil {
|
||||||
return auth.Err()
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ping := client.Ping()
|
ping := client.Ping()
|
||||||
if ping.Err() != nil {
|
if err := ping.Err(); err != nil {
|
||||||
return ping.Err()
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -70,14 +70,14 @@ Running commands
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
set := redisClient.Set("key", "hello")
|
set := redisClient.Set("key", "hello")
|
||||||
if set.Err() != nil {
|
if err := set.Err(); err != nil {
|
||||||
panic(set.Err())
|
panic(err)
|
||||||
}
|
}
|
||||||
ok := set.Val()
|
ok := set.Val()
|
||||||
|
|
||||||
get := redisClient.Get("key")
|
get := redisClient.Get("key")
|
||||||
if get.Err() != nil && get.Err() != redis.Nil {
|
if err := get.Err(); err != nil && err != redis.Nil {
|
||||||
panic(get.Err())
|
panic(err)
|
||||||
}
|
}
|
||||||
val := get.Val()
|
val := get.Val()
|
||||||
|
|
||||||
|
@ -116,12 +116,12 @@ Or:
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
if setReq.Err() != nil {
|
if err := setReq.Err(); err != nil {
|
||||||
panic(setReq.Err())
|
panic(err
|
||||||
}
|
}
|
||||||
|
|
||||||
if getReq.Err() != nil && getReq.Err() != redis.Nil {
|
if err := getReq.Err(); err != nil && err != redis.Nil {
|
||||||
panic(getReq.Err())
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Multi/Exec
|
Multi/Exec
|
||||||
|
@ -131,8 +131,8 @@ Example:
|
||||||
|
|
||||||
func transaction(multi *redis.MultiClient) ([]redis.Req, error) {
|
func transaction(multi *redis.MultiClient) ([]redis.Req, error) {
|
||||||
get := multiClient.Get("key")
|
get := multiClient.Get("key")
|
||||||
if get.Err() != nil {
|
if err := get.Err(); err != nil {
|
||||||
panic(get.Err())
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
reqs, err = multiClient.Exec(func() {
|
reqs, err = multiClient.Exec(func() {
|
||||||
|
@ -152,8 +152,8 @@ Example:
|
||||||
defer multiClient.Close()
|
defer multiClient.Close()
|
||||||
|
|
||||||
watch := multiClient.Watch("key")
|
watch := multiClient.Watch("key")
|
||||||
if watch.Err() != nil {
|
if err := watch.Err(); err != nil {
|
||||||
panic(watch.Err())
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
reqs, err := transaction(multiClient)
|
reqs, err := transaction(multiClient)
|
||||||
|
@ -170,8 +170,8 @@ Pub/sub
|
||||||
Publish:
|
Publish:
|
||||||
|
|
||||||
pub := redisClient.Publish("mychannel", "hello")
|
pub := redisClient.Publish("mychannel", "hello")
|
||||||
if pub.Err() != nil {
|
if err := pub.Err(); err != nil {
|
||||||
panic(pub.Err())
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Subscribe:
|
Subscribe:
|
||||||
|
@ -219,8 +219,8 @@ Example:
|
||||||
}
|
}
|
||||||
|
|
||||||
get := Get(redisClient, "key")
|
get := Get(redisClient, "key")
|
||||||
if get.Err() != nil && get.Err() != redis.Nil {
|
if err := get.Err(); err != nil && err != redis.Nil {
|
||||||
panic(get.Err())
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection pool
|
Connection pool
|
||||||
|
|
|
@ -28,6 +28,10 @@ func (c *Client) Ping() *StatusReq {
|
||||||
return req
|
return req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) Quit() *StatusReq {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) Select(index int64) *StatusReq {
|
func (c *Client) Select(index int64) *StatusReq {
|
||||||
req := NewStatusReq("SELECT", strconv.FormatInt(index, 10))
|
req := NewStatusReq("SELECT", strconv.FormatInt(index, 10))
|
||||||
c.Process(req)
|
c.Process(req)
|
||||||
|
|
Loading…
Reference in New Issue