MCPcopy
hub / github.com/redis/go-redis / GetEx

Method GetEx

string_commands.go:162–178  ·  view source on GitHub ↗

GetEx An expiration of zero removes the TTL associated with the key (i.e. GETEX key persist). Requires Redis >= 6.2.0.

(ctx context.Context, key string, expiration time.Duration)

Source from the content-addressed store, hash-verified

160// GetEx An expiration of zero removes the TTL associated with the key (i.e. GETEX key persist).
161// Requires Redis >= 6.2.0.
162func (c cmdable) GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd {
163 args := make([]interface{}, 0, 4)
164 args = append(args, "getex", key)
165 if expiration > 0 {
166 if usePrecise(expiration) {
167 args = append(args, "px", formatMs(ctx, expiration))
168 } else {
169 args = append(args, "ex", formatSec(ctx, expiration))
170 }
171 } else if expiration == 0 {
172 args = append(args, "persist")
173 }
174
175 cmd := NewStringCmd(ctx, args...)
176 _ = c(ctx, cmd)
177 return cmd
178}
179
180// GetDel redis-server version >= 6.2.0.
181func (c cmdable) GetDel(ctx context.Context, key string) *StringCmd {

Callers

nothing calls this directly

Calls 4

usePreciseFunction · 0.85
formatMsFunction · 0.85
formatSecFunction · 0.85
NewStringCmdFunction · 0.85

Tested by

no test coverage detected