diff --git a/.travis.yml b/.travis.yml index 1d042e4..2e8f813 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,5 @@ install: - go get gopkg.in/bsm/ratelimit.v1 - go get github.com/onsi/ginkgo - go get github.com/onsi/gomega - - go get github.com/garyburd/redigo/redis - mkdir -p $HOME/gopath/src/gopkg.in - - mv $HOME/gopath/src/github.com/go-redis/redis $HOME/gopath/src/gopkg.in/redis.v4 - - cd $HOME/gopath/src/gopkg.in/redis.v4 + - mv `pwd` $HOME/gopath/src/gopkg.in/redis.v5 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d3f8544 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# v5 + + - *Important*. ClusterClient and Ring now chose random node/shard when command does not have any keys or command info is not fully available. Also clients use EVAL and EVALSHA keys to pick the right node. diff --git a/bench_test.go b/bench_test.go index 0c40cf3..0b57699 100644 --- a/bench_test.go +++ b/bench_test.go @@ -5,9 +5,7 @@ import ( "testing" "time" - redigo "github.com/garyburd/redigo/redis" - - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) func benchmarkRedisClient(poolSize int) *redis.Client { @@ -71,7 +69,7 @@ func BenchmarkRedisGetNil(b *testing.B) { }) } -func benchmarkSetGoRedis(b *testing.B, poolSize, payloadSize int) { +func benchmarkSetRedis(b *testing.B, poolSize, payloadSize int) { client := benchmarkRedisClient(poolSize) defer client.Close() @@ -88,93 +86,36 @@ func benchmarkSetGoRedis(b *testing.B, poolSize, payloadSize int) { }) } -func BenchmarkSetGoRedis10Conns64Bytes(b *testing.B) { - benchmarkSetGoRedis(b, 10, 64) +func BenchmarkSetRedis10Conns64Bytes(b *testing.B) { + benchmarkSetRedis(b, 10, 64) } -func BenchmarkSetGoRedis100Conns64Bytes(b *testing.B) { - benchmarkSetGoRedis(b, 100, 64) +func BenchmarkSetRedis100Conns64Bytes(b *testing.B) { + benchmarkSetRedis(b, 100, 64) } -func BenchmarkSetGoRedis10Conns1KB(b *testing.B) { - benchmarkSetGoRedis(b, 10, 1024) +func BenchmarkSetRedis10Conns1KB(b *testing.B) { + benchmarkSetRedis(b, 10, 1024) } -func BenchmarkSetGoRedis100Conns1KB(b *testing.B) { - benchmarkSetGoRedis(b, 100, 1024) +func BenchmarkSetRedis100Conns1KB(b *testing.B) { + benchmarkSetRedis(b, 100, 1024) } -func BenchmarkSetGoRedis10Conns10KB(b *testing.B) { - benchmarkSetGoRedis(b, 10, 10*1024) +func BenchmarkSetRedis10Conns10KB(b *testing.B) { + benchmarkSetRedis(b, 10, 10*1024) } -func BenchmarkSetGoRedis100Conns10KB(b *testing.B) { - benchmarkSetGoRedis(b, 100, 10*1024) +func BenchmarkSetRedis100Conns10KB(b *testing.B) { + benchmarkSetRedis(b, 100, 10*1024) } -func BenchmarkSetGoRedis10Conns1MB(b *testing.B) { - benchmarkSetGoRedis(b, 10, 1024*1024) +func BenchmarkSetRedis10Conns1MB(b *testing.B) { + benchmarkSetRedis(b, 10, 1024*1024) } -func BenchmarkSetGoRedis100Conns1MB(b *testing.B) { - benchmarkSetGoRedis(b, 100, 1024*1024) -} - -func benchmarkSetRedigo(b *testing.B, poolSize, payloadSize int) { - pool := &redigo.Pool{ - Dial: func() (redigo.Conn, error) { - return redigo.DialTimeout("tcp", ":6379", time.Second, time.Second, time.Second) - }, - MaxActive: poolSize, - MaxIdle: poolSize, - } - defer pool.Close() - - value := string(bytes.Repeat([]byte{'1'}, payloadSize)) - - b.ResetTimer() - - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - conn := pool.Get() - if _, err := conn.Do("SET", "key", value); err != nil { - b.Fatal(err) - } - conn.Close() - } - }) -} - -func BenchmarkSetRedigo10Conns64Bytes(b *testing.B) { - benchmarkSetRedigo(b, 10, 64) -} - -func BenchmarkSetRedigo100Conns64Bytes(b *testing.B) { - benchmarkSetRedigo(b, 100, 64) -} - -func BenchmarkSetRedigo10Conns1KB(b *testing.B) { - benchmarkSetRedigo(b, 10, 1024) -} - -func BenchmarkSetRedigo100Conns1KB(b *testing.B) { - benchmarkSetRedigo(b, 100, 1024) -} - -func BenchmarkSetRedigo10Conns10KB(b *testing.B) { - benchmarkSetRedigo(b, 10, 10*1024) -} - -func BenchmarkSetRedigo100Conns10KB(b *testing.B) { - benchmarkSetRedigo(b, 100, 10*1024) -} - -func BenchmarkSetRedigo10Conns1MB(b *testing.B) { - benchmarkSetRedigo(b, 10, 1024*1024) -} - -func BenchmarkSetRedigo100Conns1MB(b *testing.B) { - benchmarkSetRedigo(b, 100, 1024*1024) +func BenchmarkSetRedis100Conns1MB(b *testing.B) { + benchmarkSetRedis(b, 100, 1024*1024) } func BenchmarkRedisSetGetBytes(b *testing.B) { diff --git a/cluster.go b/cluster.go index 6aea41b..cc8b300 100644 --- a/cluster.go +++ b/cluster.go @@ -6,10 +6,10 @@ import ( "sync/atomic" "time" - "gopkg.in/redis.v4/internal" - "gopkg.in/redis.v4/internal/errors" - "gopkg.in/redis.v4/internal/hashtag" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal" + "gopkg.in/redis.v5/internal/errors" + "gopkg.in/redis.v5/internal/hashtag" + "gopkg.in/redis.v5/internal/pool" ) // ClusterOptions are used to configure a cluster client and should be diff --git a/cluster_test.go b/cluster_test.go index 74b260f..367a6e3 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -13,8 +13,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" - "gopkg.in/redis.v4/internal/hashtag" + "gopkg.in/redis.v5" + "gopkg.in/redis.v5/internal/hashtag" ) type clusterScenario struct { diff --git a/command.go b/command.go index 7613203..41fde30 100644 --- a/command.go +++ b/command.go @@ -7,10 +7,9 @@ import ( "strings" "time" - "github.com/go-redis/redis/internal" - - "gopkg.in/redis.v4/internal/pool" - "gopkg.in/redis.v4/internal/proto" + "gopkg.in/redis.v5/internal" + "gopkg.in/redis.v5/internal/pool" + "gopkg.in/redis.v5/internal/proto" ) var ( diff --git a/command_test.go b/command_test.go index ab31f3f..216a7b0 100644 --- a/command_test.go +++ b/command_test.go @@ -4,7 +4,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("Cmd", func() { diff --git a/commands.go b/commands.go index f117329..078242f 100644 --- a/commands.go +++ b/commands.go @@ -5,8 +5,8 @@ import ( "strconv" "time" - "gopkg.in/redis.v4/internal" - "gopkg.in/redis.v4/internal/errors" + "gopkg.in/redis.v5/internal" + "gopkg.in/redis.v5/internal/errors" ) func readTimeout(timeout time.Duration) time.Duration { diff --git a/commands_test.go b/commands_test.go index c89c333..e613d4a 100644 --- a/commands_test.go +++ b/commands_test.go @@ -9,7 +9,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("Commands", func() { diff --git a/example_test.go b/example_test.go index 71d06c4..1aef66f 100644 --- a/example_test.go +++ b/example_test.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var client *redis.Client diff --git a/export_test.go b/export_test.go index ff37e81..d36f867 100644 --- a/export_test.go +++ b/export_test.go @@ -3,7 +3,7 @@ package redis import ( "time" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal/pool" ) func (c *baseClient) Pool() pool.Pooler { diff --git a/internal/pool/bench_test.go b/internal/pool/bench_test.go index 663abc0..be2c305 100644 --- a/internal/pool/bench_test.go +++ b/internal/pool/bench_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal/pool" ) func benchmarkPoolGetPut(b *testing.B, poolSize int) { diff --git a/internal/pool/conn.go b/internal/pool/conn.go index bb0922f..785fc21 100644 --- a/internal/pool/conn.go +++ b/internal/pool/conn.go @@ -4,7 +4,7 @@ import ( "net" "time" - "gopkg.in/redis.v4/internal/proto" + "gopkg.in/redis.v5/internal/proto" ) const defaultBufSize = 4096 diff --git a/internal/pool/pool.go b/internal/pool/pool.go index bd1c413..389a3d2 100644 --- a/internal/pool/pool.go +++ b/internal/pool/pool.go @@ -10,7 +10,7 @@ import ( "gopkg.in/bsm/ratelimit.v1" - "gopkg.in/redis.v4/internal" + "gopkg.in/redis.v5/internal" ) var ( diff --git a/internal/pool/pool_test.go b/internal/pool/pool_test.go index 425ce92..7ba35fd 100644 --- a/internal/pool/pool_test.go +++ b/internal/pool/pool_test.go @@ -8,7 +8,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal/pool" ) var _ = Describe("ConnPool", func() { diff --git a/internal/proto/proto.go b/internal/proto/proto.go index c63caaa..00d5f6b 100644 --- a/internal/proto/proto.go +++ b/internal/proto/proto.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "gopkg.in/redis.v4/internal/errors" + "gopkg.in/redis.v5/internal/errors" ) const ( diff --git a/internal/proto/reader.go b/internal/proto/reader.go index 9d2f51a..412eec6 100644 --- a/internal/proto/reader.go +++ b/internal/proto/reader.go @@ -7,7 +7,7 @@ import ( "io" "strconv" - ierrors "gopkg.in/redis.v4/internal/errors" + ierrors "gopkg.in/redis.v5/internal/errors" ) type MultiBulkParse func(*Reader, int64) (interface{}, error) diff --git a/internal/proto/reader_test.go b/internal/proto/reader_test.go index 5169262..421344b 100644 --- a/internal/proto/reader_test.go +++ b/internal/proto/reader_test.go @@ -7,7 +7,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4/internal/proto" + + "gopkg.in/redis.v5/internal/proto" ) var _ = Describe("Reader", func() { diff --git a/internal/proto/writebuffer_test.go b/internal/proto/writebuffer_test.go index 6316ded..36593af 100644 --- a/internal/proto/writebuffer_test.go +++ b/internal/proto/writebuffer_test.go @@ -6,7 +6,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4/internal/proto" + + "gopkg.in/redis.v5/internal/proto" ) var _ = Describe("WriteBuffer", func() { diff --git a/iterator_test.go b/iterator_test.go index 7b30176..7200c14 100644 --- a/iterator_test.go +++ b/iterator_test.go @@ -6,7 +6,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("ScanIterator", func() { diff --git a/main_test.go b/main_test.go index a9afa82..67886e4 100644 --- a/main_test.go +++ b/main_test.go @@ -14,7 +14,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) const ( @@ -94,7 +94,7 @@ var _ = AfterSuite(func() { func TestGinkgoSuite(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "gopkg.in/redis.v4") + RunSpecs(t, "gopkg.in/redis.v5") } //------------------------------------------------------------------------------ diff --git a/options.go b/options.go index bfe2e8a..376fa6b 100644 --- a/options.go +++ b/options.go @@ -4,7 +4,7 @@ import ( "net" "time" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal/pool" ) type Options struct { diff --git a/parser.go b/parser.go index a4ad4e2..50b2a95 100644 --- a/parser.go +++ b/parser.go @@ -5,7 +5,7 @@ import ( "net" "strconv" - "gopkg.in/redis.v4/internal/proto" + "gopkg.in/redis.v5/internal/proto" ) // Implements proto.MultiBulkParse diff --git a/pipeline.go b/pipeline.go index bf80d40..fe226ec 100644 --- a/pipeline.go +++ b/pipeline.go @@ -4,8 +4,8 @@ import ( "sync" "sync/atomic" - "gopkg.in/redis.v4/internal/errors" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal/errors" + "gopkg.in/redis.v5/internal/pool" ) // Pipeline implements pipelining as described in diff --git a/pipeline_test.go b/pipeline_test.go index c3a37f6..74cdd38 100644 --- a/pipeline_test.go +++ b/pipeline_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("Pipelining", func() { diff --git a/pool_test.go b/pool_test.go index 2b0d2ad..1adea5e 100644 --- a/pool_test.go +++ b/pool_test.go @@ -6,8 +6,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5" + "gopkg.in/redis.v5/internal/pool" ) var _ = Describe("pool", func() { diff --git a/pubsub.go b/pubsub.go index 796bd4a..78136f5 100644 --- a/pubsub.go +++ b/pubsub.go @@ -5,9 +5,9 @@ import ( "net" "time" - "gopkg.in/redis.v4/internal" - "gopkg.in/redis.v4/internal/errors" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal" + "gopkg.in/redis.v5/internal/errors" + "gopkg.in/redis.v5/internal/pool" ) // PubSub implements Pub/Sub commands as described in diff --git a/pubsub_test.go b/pubsub_test.go index 957d303..ecbea76 100644 --- a/pubsub_test.go +++ b/pubsub_test.go @@ -9,7 +9,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("PubSub", func() { diff --git a/race_test.go b/race_test.go index ca4fb7f..cf093f2 100644 --- a/race_test.go +++ b/race_test.go @@ -11,8 +11,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5" + "gopkg.in/redis.v5/internal/pool" ) var _ = Describe("races", func() { diff --git a/redis.go b/redis.go index 60df328..9c8b490 100644 --- a/redis.go +++ b/redis.go @@ -1,12 +1,12 @@ -package redis // import "gopkg.in/redis.v4" +package redis // import "gopkg.in/redis.v5" import ( "fmt" "log" - "gopkg.in/redis.v4/internal" - "gopkg.in/redis.v4/internal/errors" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal" + "gopkg.in/redis.v5/internal/errors" + "gopkg.in/redis.v5/internal/pool" ) // Redis nil reply, .e.g. when key does not exist. diff --git a/redis_test.go b/redis_test.go index 0b59547..8d5f651 100644 --- a/redis_test.go +++ b/redis_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("Client", func() { diff --git a/ring.go b/ring.go index 52badb3..77193f3 100644 --- a/ring.go +++ b/ring.go @@ -9,10 +9,10 @@ import ( "sync/atomic" "time" - "gopkg.in/redis.v4/internal" - "gopkg.in/redis.v4/internal/consistenthash" - "gopkg.in/redis.v4/internal/hashtag" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal" + "gopkg.in/redis.v5/internal/consistenthash" + "gopkg.in/redis.v5/internal/hashtag" + "gopkg.in/redis.v5/internal/pool" ) var errRingShardsDown = errors.New("redis: all ring shards are down") diff --git a/ring_test.go b/ring_test.go index 0ab258d..5e9d16f 100644 --- a/ring_test.go +++ b/ring_test.go @@ -8,7 +8,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("Redis Ring", func() { diff --git a/sentinel.go b/sentinel.go index 66f0974..0849dda 100644 --- a/sentinel.go +++ b/sentinel.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "gopkg.in/redis.v4/internal" - "gopkg.in/redis.v4/internal/pool" + "gopkg.in/redis.v5/internal" + "gopkg.in/redis.v5/internal/pool" ) //------------------------------------------------------------------------------ diff --git a/sentinel_test.go b/sentinel_test.go index 165cce6..d703857 100644 --- a/sentinel_test.go +++ b/sentinel_test.go @@ -4,7 +4,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("Sentinel", func() { diff --git a/tx.go b/tx.go index 62e7701..ba2fd93 100644 --- a/tx.go +++ b/tx.go @@ -4,10 +4,10 @@ import ( "errors" "fmt" - "gopkg.in/redis.v4/internal" - ierrors "gopkg.in/redis.v4/internal/errors" - "gopkg.in/redis.v4/internal/pool" - "gopkg.in/redis.v4/internal/proto" + "gopkg.in/redis.v5/internal" + ierrors "gopkg.in/redis.v5/internal/errors" + "gopkg.in/redis.v5/internal/pool" + "gopkg.in/redis.v5/internal/proto" ) // Redis transaction failed. diff --git a/tx_test.go b/tx_test.go index ddb9ddf..03d220b 100644 --- a/tx_test.go +++ b/tx_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "gopkg.in/redis.v4" + "gopkg.in/redis.v5" ) var _ = Describe("Tx", func() {