mirror of https://github.com/go-redis/redis.git
Merge pull request #107 from go-redis/fix/psetex-setex-remove
Remove PSetEx and SetEx. Set should be used instead.
This commit is contained in:
commit
bbfbc5f668
12
commands.go
12
commands.go
|
@ -470,12 +470,6 @@ func (c *commandable) MSetNX(pairs ...string) *BoolCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c *commandable) PSetEx(key string, expiration time.Duration, value string) *StatusCmd {
|
||||
cmd := NewStatusCmd("PSETEX", key, formatMs(expiration), value)
|
||||
c.Process(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c *commandable) Set(key, value string, expiration time.Duration) *StatusCmd {
|
||||
args := []string{"SET", key, value}
|
||||
if expiration > 0 {
|
||||
|
@ -501,12 +495,6 @@ func (c *commandable) SetBit(key string, offset int64, value int) *IntCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c *commandable) SetEx(key string, expiration time.Duration, value string) *StatusCmd {
|
||||
cmd := NewStatusCmd("SETEX", key, formatSec(expiration), value)
|
||||
c.Process(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c *commandable) SetNX(key, value string, expiration time.Duration) *BoolCmd {
|
||||
var cmd *BoolCmd
|
||||
if expiration == 0 {
|
||||
|
|
|
@ -873,22 +873,6 @@ var _ = Describe("Commands", func() {
|
|||
Expect(mSetNX.Val()).To(Equal(false))
|
||||
})
|
||||
|
||||
It("should PSetEx", func() {
|
||||
expiration := 50 * time.Millisecond
|
||||
psetex := client.PSetEx("key", expiration, "hello")
|
||||
Expect(psetex.Err()).NotTo(HaveOccurred())
|
||||
Expect(psetex.Val()).To(Equal("OK"))
|
||||
|
||||
pttl := client.PTTL("key")
|
||||
Expect(pttl.Err()).NotTo(HaveOccurred())
|
||||
Expect(pttl.Val() <= expiration).To(Equal(true))
|
||||
Expect(pttl.Val() >= expiration-time.Millisecond).To(Equal(true))
|
||||
|
||||
get := client.Get("key")
|
||||
Expect(get.Err()).NotTo(HaveOccurred())
|
||||
Expect(get.Val()).To(Equal("hello"))
|
||||
})
|
||||
|
||||
It("should Set with expiration", func() {
|
||||
err := client.Set("key", "hello", 100*time.Millisecond).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -912,16 +896,6 @@ var _ = Describe("Commands", func() {
|
|||
Expect(get.Val()).To(Equal("hello"))
|
||||
})
|
||||
|
||||
It("should SetEx", func() {
|
||||
setEx := client.SetEx("key", 10*time.Second, "hello")
|
||||
Expect(setEx.Err()).NotTo(HaveOccurred())
|
||||
Expect(setEx.Val()).To(Equal("OK"))
|
||||
|
||||
ttl := client.TTL("key")
|
||||
Expect(ttl.Err()).NotTo(HaveOccurred())
|
||||
Expect(ttl.Val()).To(Equal(10 * time.Second))
|
||||
})
|
||||
|
||||
It("should SetNX", func() {
|
||||
setNX := client.SetNX("key", "hello", 0)
|
||||
Expect(setNX.Err()).NotTo(HaveOccurred())
|
||||
|
|
Loading…
Reference in New Issue