PExpireAt has the same effect and semantic as expireAt, but the Unix time at which the key will expire is specified in milliseconds instead of seconds
(ctx *Context, txn *db.Transaction)
| 133 | // PExpireAt has the same effect and semantic as expireAt, |
| 134 | // but the Unix time at which the key will expire is specified in milliseconds instead of seconds |
| 135 | func PExpireAt(ctx *Context, txn *db.Transaction) (OnCommit, error) { |
| 136 | kv := txn.Kv() |
| 137 | key := []byte(ctx.Args[0]) |
| 138 | ms, err := strconv.ParseInt(ctx.Args[1], 10, 64) |
| 139 | if err != nil { |
| 140 | return nil, ErrInteger |
| 141 | } |
| 142 | at := int64(time.Millisecond * time.Duration(ms)) |
| 143 | if at <= 0 { |
| 144 | at = 1 |
| 145 | } |
| 146 | if err := kv.ExpireAt(key, at); err != nil { |
| 147 | if err == db.ErrKeyNotFound { |
| 148 | return Integer(ctx.Out, 0), nil |
| 149 | } |
| 150 | return nil, errors.New("ERR " + err.Error()) |
| 151 | } |
| 152 | return Integer(ctx.Out, 1), nil |
| 153 | } |
| 154 | |
| 155 | // TTL returns the remaining time to live of a key that has a timeout |
| 156 | func TTL(ctx *Context, txn *db.Transaction) (OnCommit, error) { |