MCPcopy Create free account
hub / github.com/distributedio/titan / PExpireAt

Function PExpireAt

command/keys.go:135–153  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
135func 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
156func TTL(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 4

IntegerFunction · 0.85
KvMethod · 0.80
ExpireAtMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected