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)
| 160 | // GetEx An expiration of zero removes the TTL associated with the key (i.e. GETEX key persist). |
| 161 | // Requires Redis >= 6.2.0. |
| 162 | func (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. |
| 181 | func (c cmdable) GetDel(ctx context.Context, key string) *StringCmd { |
nothing calls this directly
no test coverage detected