diff --git a/bench_test.go b/bench_test.go index 85514066..f6b75c72 100644 --- a/bench_test.go +++ b/bench_test.go @@ -16,7 +16,7 @@ func benchmarkRedisClient(poolSize int) *redis.Client { WriteTimeout: time.Second, PoolSize: poolSize, }) - if err := client.FlushDb().Err(); err != nil { + if err := client.FlushDB().Err(); err != nil { panic(err) } return client diff --git a/cluster_test.go b/cluster_test.go index 1e55be6e..3a69255a 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -478,7 +478,7 @@ var _ = Describe("ClusterClient", func() { } err := client.ForEachMaster(func(master *redis.Client) error { - return master.FlushDb().Err() + return master.FlushDB().Err() }) Expect(err).NotTo(HaveOccurred()) @@ -496,7 +496,7 @@ var _ = Describe("ClusterClient", func() { client = cluster.clusterClient(opt) _ = client.ForEachMaster(func(master *redis.Client) error { - return master.FlushDb().Err() + return master.FlushDB().Err() }) }) @@ -514,12 +514,12 @@ var _ = Describe("ClusterClient", func() { client = cluster.clusterClient(opt) _ = client.ForEachMaster(func(master *redis.Client) error { - return master.FlushDb().Err() + return master.FlushDB().Err() }) }) AfterEach(func() { - client.FlushDb() + client.FlushDB() Expect(client.Close()).NotTo(HaveOccurred()) }) diff --git a/command_test.go b/command_test.go index 920f14b7..e42375ed 100644 --- a/command_test.go +++ b/command_test.go @@ -12,7 +12,7 @@ var _ = Describe("Cmd", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() { diff --git a/commands.go b/commands.go index 3956cf74..4ea78777 100644 --- a/commands.go +++ b/commands.go @@ -192,7 +192,9 @@ type Cmdable interface { ConfigSet(parameter, value string) *StatusCmd DbSize() *IntCmd FlushAll() *StatusCmd - FlushDb() *StatusCmd + FlushAllAsync() *StatusCmd + FlushDB() *StatusCmd + FlushDBAsync() *StatusCmd Info(section ...string) *StringCmd LastSave() *IntCmd Save() *StatusCmd @@ -1685,12 +1687,31 @@ func (c *cmdable) FlushAll() *StatusCmd { return cmd } +func (c *cmdable) FlushAllAsync() *StatusCmd { + cmd := NewStatusCmd("flushall", "async") + c.process(cmd) + return cmd +} + +// Deprecated. Use FlushDB instead. func (c *cmdable) FlushDb() *StatusCmd { cmd := NewStatusCmd("flushdb") c.process(cmd) return cmd } +func (c *cmdable) FlushDB() *StatusCmd { + cmd := NewStatusCmd("flushdb") + c.process(cmd) + return cmd +} + +func (c *cmdable) FlushDBAsync() *StatusCmd { + cmd := NewStatusCmd("flushdb", "async") + c.process(cmd) + return cmd +} + func (c *cmdable) Info(section ...string) *StringCmd { args := []interface{}{"info"} if len(section) > 0 { diff --git a/commands_test.go b/commands_test.go index 7e5d4010..64a50b50 100644 --- a/commands_test.go +++ b/commands_test.go @@ -17,7 +17,7 @@ var _ = Describe("Commands", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() { @@ -352,7 +352,7 @@ var _ = Describe("Commands", func() { pipe := client.Pipeline() pipe.Select(2) get = pipe.Get("key") - pipe.FlushDb() + pipe.FlushDB() _, err := pipe.Exec() Expect(err).NotTo(HaveOccurred()) diff --git a/example_test.go b/example_test.go index fbb92c17..94090416 100644 --- a/example_test.go +++ b/example_test.go @@ -20,7 +20,7 @@ func init() { PoolSize: 10, PoolTimeout: 30 * time.Second, }) - client.FlushDb() + client.FlushDB() } func ExampleNewClient() { @@ -147,7 +147,7 @@ func ExampleClient_BLPop() { } func ExampleClient_Scan() { - client.FlushDb() + client.FlushDB() for i := 0; i < 33; i++ { err := client.Set(fmt.Sprintf("key%d", i), "value", 0).Err() if err != nil { diff --git a/iterator_test.go b/iterator_test.go index 954165cc..a2e62381 100644 --- a/iterator_test.go +++ b/iterator_test.go @@ -45,7 +45,7 @@ var _ = Describe("ScanIterator", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() { diff --git a/pipeline_test.go b/pipeline_test.go index 5dc5f94a..11896c6b 100644 --- a/pipeline_test.go +++ b/pipeline_test.go @@ -13,7 +13,7 @@ var _ = Describe("pipelining", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() { diff --git a/pool_test.go b/pool_test.go index 9d33559b..34a548a6 100644 --- a/pool_test.go +++ b/pool_test.go @@ -14,7 +14,7 @@ var _ = Describe("pool", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() { diff --git a/pubsub_test.go b/pubsub_test.go index b17ca7ad..d03270c3 100644 --- a/pubsub_test.go +++ b/pubsub_test.go @@ -17,7 +17,7 @@ var _ = Describe("PubSub", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() { diff --git a/race_test.go b/race_test.go index 439e5e29..5bcb0768 100644 --- a/race_test.go +++ b/race_test.go @@ -20,7 +20,7 @@ var _ = Describe("races", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).To(BeNil()) + Expect(client.FlushDB().Err()).To(BeNil()) C, N = 10, 1000 if testing.Short() { diff --git a/redis_test.go b/redis_test.go index 972b67be..49d3fb32 100644 --- a/redis_test.go +++ b/redis_test.go @@ -16,7 +16,7 @@ var _ = Describe("Client", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() { @@ -111,7 +111,7 @@ var _ = Describe("Client", func() { Addr: redisAddr, DB: 2, }) - Expect(db2.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(db2.FlushDB().Err()).NotTo(HaveOccurred()) Expect(db2.Get("db").Err()).To(Equal(redis.Nil)) Expect(db2.Set("db", 2, 0).Err()).NotTo(HaveOccurred()) @@ -121,7 +121,7 @@ var _ = Describe("Client", func() { Expect(client.Get("db").Err()).To(Equal(redis.Nil)) - Expect(db2.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(db2.FlushDB().Err()).NotTo(HaveOccurred()) Expect(db2.Close()).NotTo(HaveOccurred()) }) diff --git a/ring_test.go b/ring_test.go index a61ee96a..0cad4298 100644 --- a/ring_test.go +++ b/ring_test.go @@ -29,7 +29,7 @@ var _ = Describe("Redis Ring", func() { ring = redis.NewRing(opt) err := ring.ForEachShard(func(cl *redis.Client) error { - return cl.FlushDb().Err() + return cl.FlushDB().Err() }) Expect(err).NotTo(HaveOccurred()) }) diff --git a/sentinel_test.go b/sentinel_test.go index 04bbabd1..f1f580f3 100644 --- a/sentinel_test.go +++ b/sentinel_test.go @@ -15,7 +15,7 @@ var _ = Describe("Sentinel", func() { MasterName: sentinelName, SentinelAddrs: []string{":" + sentinelPort}, }) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() { diff --git a/tx_test.go b/tx_test.go index 8d9cc036..de597ff0 100644 --- a/tx_test.go +++ b/tx_test.go @@ -15,7 +15,7 @@ var _ = Describe("Tx", func() { BeforeEach(func() { client = redis.NewClient(redisOptions()) - Expect(client.FlushDb().Err()).NotTo(HaveOccurred()) + Expect(client.FlushDB().Err()).NotTo(HaveOccurred()) }) AfterEach(func() {