1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-06 01:35:48 +03:00

Rename GetEX to GetEx to better distinguish from XX and NX suffixes

This commit is contained in:
Vladimir Mihailenco
2021-03-27 17:22:10 +02:00
parent 2be507f8e7
commit 1e30221353
2 changed files with 6 additions and 5 deletions

View File

@@ -117,7 +117,7 @@ type Cmdable interface {
Get(ctx context.Context, key string) *StringCmd Get(ctx context.Context, key string) *StringCmd
GetRange(ctx context.Context, key string, start, end int64) *StringCmd GetRange(ctx context.Context, key string, start, end int64) *StringCmd
GetSet(ctx context.Context, key string, value interface{}) *StringCmd GetSet(ctx context.Context, key string, value interface{}) *StringCmd
GetEX(ctx context.Context, key string, expiration time.Duration) *StringCmd GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd
GetDel(ctx context.Context, key string) *StringCmd GetDel(ctx context.Context, key string) *StringCmd
Incr(ctx context.Context, key string) *IntCmd Incr(ctx context.Context, key string) *IntCmd
IncrBy(ctx context.Context, key string, value int64) *IntCmd IncrBy(ctx context.Context, key string, value int64) *IntCmd
@@ -127,6 +127,7 @@ type Cmdable interface {
MSetNX(ctx context.Context, values ...interface{}) *BoolCmd MSetNX(ctx context.Context, values ...interface{}) *BoolCmd
Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd
// TODO: rename to SetEx
SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
@@ -714,9 +715,9 @@ func (c cmdable) GetSet(ctx context.Context, key string, value interface{}) *Str
return cmd return cmd
} }
// redis-server version >= 6.2.0. // An expiration of zero removes the TTL associated with the key (i.e. GETEX key persist).
// A expiration of zero remove the time to live associated with the key(GetEX key persist). // Requires Redis >= 6.2.0.
func (c cmdable) GetEX(ctx context.Context, key string, expiration time.Duration) *StringCmd { func (c cmdable) GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd {
args := make([]interface{}, 0, 4) args := make([]interface{}, 0, 4)
args = append(args, "getex", key) args = append(args, "getex", key)
if expiration > 0 { if expiration > 0 {

View File

@@ -1092,7 +1092,7 @@ var _ = Describe("Commands", func() {
Expect(ttl.Err()).NotTo(HaveOccurred()) Expect(ttl.Err()).NotTo(HaveOccurred())
Expect(ttl.Val()).To(BeNumerically("~", 100*time.Second, 3*time.Second)) Expect(ttl.Val()).To(BeNumerically("~", 100*time.Second, 3*time.Second))
getEX := client.GetEX(ctx, "key", 200*time.Second) getEX := client.GetEx(ctx, "key", 200*time.Second)
Expect(getEX.Err()).NotTo(HaveOccurred()) Expect(getEX.Err()).NotTo(HaveOccurred())
Expect(getEX.Val()).To(Equal("value")) Expect(getEX.Val()).To(Equal("value"))