forked from mirror/redis
Code cleanup
This commit is contained in:
parent
18dcec2144
commit
ef95182d29
|
@ -338,8 +338,6 @@ type ClusterClient struct {
|
||||||
|
|
||||||
// Reports where slots reloading is in progress.
|
// Reports where slots reloading is in progress.
|
||||||
reloading uint32
|
reloading uint32
|
||||||
|
|
||||||
closed bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClusterClient returns a Redis Cluster client as described in
|
// NewClusterClient returns a Redis Cluster client as described in
|
||||||
|
|
|
@ -2316,6 +2316,7 @@ var _ = Describe("Commands", func() {
|
||||||
zAdd = client.ZAdd("zset", redis.Z{0, "b"})
|
zAdd = client.ZAdd("zset", redis.Z{0, "b"})
|
||||||
Expect(zAdd.Err()).NotTo(HaveOccurred())
|
Expect(zAdd.Err()).NotTo(HaveOccurred())
|
||||||
zAdd = client.ZAdd("zset", redis.Z{0, "c"})
|
zAdd = client.ZAdd("zset", redis.Z{0, "c"})
|
||||||
|
Expect(zAdd.Err()).NotTo(HaveOccurred())
|
||||||
|
|
||||||
zRangeByLex := client.ZRangeByLex("zset", redis.ZRangeBy{
|
zRangeByLex := client.ZRangeByLex("zset", redis.ZRangeBy{
|
||||||
Min: "-",
|
Min: "-",
|
||||||
|
|
|
@ -65,7 +65,6 @@ type ConnPool struct {
|
||||||
stats Stats
|
stats Stats
|
||||||
|
|
||||||
_closed int32 // atomic
|
_closed int32 // atomic
|
||||||
lastErr atomic.Value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Pooler = (*ConnPool)(nil)
|
var _ Pooler = (*ConnPool)(nil)
|
||||||
|
|
|
@ -6,8 +6,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
const bufferSize = 4096
|
|
||||||
|
|
||||||
type WriteBuffer struct {
|
type WriteBuffer struct {
|
||||||
b []byte
|
b []byte
|
||||||
}
|
}
|
||||||
|
|
26
parser.go
26
parser.go
|
@ -30,19 +30,6 @@ func sliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
return vals, nil
|
return vals, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements proto.MultiBulkParse
|
|
||||||
func intSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
|
||||||
ints := make([]int64, 0, n)
|
|
||||||
for i := int64(0); i < n; i++ {
|
|
||||||
n, err := rd.ReadIntReply()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ints = append(ints, n)
|
|
||||||
}
|
|
||||||
return ints, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements proto.MultiBulkParse
|
// Implements proto.MultiBulkParse
|
||||||
func boolSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
func boolSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
bools := make([]bool, 0, n)
|
bools := make([]bool, 0, n)
|
||||||
|
@ -72,19 +59,6 @@ func stringSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
return ss, nil
|
return ss, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements proto.MultiBulkParse
|
|
||||||
func floatSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
|
||||||
nn := make([]float64, 0, n)
|
|
||||||
for i := int64(0); i < n; i++ {
|
|
||||||
n, err := rd.ReadFloatReply()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
nn = append(nn, n)
|
|
||||||
}
|
|
||||||
return nn, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements proto.MultiBulkParse
|
// Implements proto.MultiBulkParse
|
||||||
func stringStringMapParser(rd *proto.Reader, n int64) (interface{}, error) {
|
func stringStringMapParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
m := make(map[string]string, n/2)
|
m := make(map[string]string, n/2)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package redis
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/internal"
|
"github.com/go-redis/redis/internal"
|
||||||
|
@ -17,7 +16,6 @@ type PubSub struct {
|
||||||
base baseClient
|
base baseClient
|
||||||
cmd *Cmd
|
cmd *Cmd
|
||||||
|
|
||||||
mu sync.Mutex
|
|
||||||
channels []string
|
channels []string
|
||||||
patterns []string
|
patterns []string
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ var _ = Describe("Client", func() {
|
||||||
|
|
||||||
It("should close pubsub without closing the client", func() {
|
It("should close pubsub without closing the client", func() {
|
||||||
pubsub, err := client.Subscribe()
|
pubsub, err := client.Subscribe()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(pubsub.Close()).NotTo(HaveOccurred())
|
Expect(pubsub.Close()).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, err = pubsub.Receive()
|
_, err = pubsub.Receive()
|
||||||
|
@ -92,6 +93,7 @@ var _ = Describe("Client", func() {
|
||||||
|
|
||||||
It("should close pubsub when client is closed", func() {
|
It("should close pubsub when client is closed", func() {
|
||||||
pubsub, err := client.Subscribe()
|
pubsub, err := client.Subscribe()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(client.Close()).NotTo(HaveOccurred())
|
Expect(client.Close()).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, err = pubsub.Receive()
|
_, err = pubsub.Receive()
|
||||||
|
|
Loading…
Reference in New Issue