Skip to content

Commit 1e30221

Browse files
committed
Rename GetEX to GetEx to better distinguish from XX and NX suffixes
1 parent 2be507f commit 1e30221

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

commands.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ type Cmdable interface {
117117
Get(ctx context.Context, key string) *StringCmd
118118
GetRange(ctx context.Context, key string, start, end int64) *StringCmd
119119
GetSet(ctx context.Context, key string, value interface{}) *StringCmd
120-
GetEX(ctx context.Context, key string, expiration time.Duration) *StringCmd
120+
GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd
121121
GetDel(ctx context.Context, key string) *StringCmd
122122
Incr(ctx context.Context, key string) *IntCmd
123123
IncrBy(ctx context.Context, key string, value int64) *IntCmd
@@ -127,6 +127,7 @@ type Cmdable interface {
127127
MSetNX(ctx context.Context, values ...interface{}) *BoolCmd
128128
Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
129129
SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd
130+
// TODO: rename to SetEx
130131
SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
131132
SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
132133
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
714715
return cmd
715716
}
716717

717-
// redis-server version >= 6.2.0.
718-
// A expiration of zero remove the time to live associated with the key(GetEX key persist).
719-
func (c cmdable) GetEX(ctx context.Context, key string, expiration time.Duration) *StringCmd {
718+
// An expiration of zero removes the TTL associated with the key (i.e. GETEX key persist).
719+
// Requires Redis >= 6.2.0.
720+
func (c cmdable) GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd {
720721
args := make([]interface{}, 0, 4)
721722
args = append(args, "getex", key)
722723
if expiration > 0 {

commands_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ var _ = Describe("Commands", func() {
10921092
Expect(ttl.Err()).NotTo(HaveOccurred())
10931093
Expect(ttl.Val()).To(BeNumerically("~", 100*time.Second, 3*time.Second))
10941094

1095-
getEX := client.GetEX(ctx, "key", 200*time.Second)
1095+
getEX := client.GetEx(ctx, "key", 200*time.Second)
10961096
Expect(getEX.Err()).NotTo(HaveOccurred())
10971097
Expect(getEX.Val()).To(Equal("value"))
10981098

0 commit comments

Comments
 (0)