handleExpiration handles common expiration logic for EXPIRE/EXPIREAT/SETEX/SETEXAT
(key []byte, timestamp int64)
| 50 | |
| 51 | // handleExpiration handles common expiration logic for EXPIRE/EXPIREAT/SETEX/SETEXAT |
| 52 | func handleExpiration(key []byte, timestamp int64) (interface{}, error) { |
| 53 | // If the timestamp is in the past, delete the key |
| 54 | if timestamp < time.Now().Unix() { |
| 55 | if _, err := ldb.Del(key); err != nil { |
| 56 | return nil, err |
| 57 | } |
| 58 | return redcon.SimpleInt(1), nil |
| 59 | } |
| 60 | |
| 61 | v, err := ldb.ExpireAt(key, timestamp) |
| 62 | if err != nil { |
| 63 | return nil, err |
| 64 | } |
| 65 | return redcon.SimpleInt(v), nil |
| 66 | } |
| 67 | |
| 68 | // cmdEXPIREAT sets an expiration timestamp for a key. |
| 69 | func cmdEXPIREAT(m uhaha.Machine, args []string) (interface{}, error) { |
no outgoing calls
no test coverage detected