MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / cmdHEXPIRE

Function cmdHEXPIRE

hashes.go:292–317  ·  view source on GitHub ↗
(m uhaha.Machine, args []string)

Source from the content-addressed store, hash-verified

290 }
291 return redcon.SimpleInt(n), nil
292}
293
294func cmdHEXPIRE(m uhaha.Machine, args []string) (interface{}, error) {
295 if len(args) != 3 {
296 return nil, uhaha.ErrWrongNumArgs
297 }
298
299 duration, err := ledis.StrInt64([]byte(args[2]), nil)
300 if err != nil {
301 return nil, err
302 }
303
304 timestamp := m.Now().Unix() + duration
305 //If the timestamp is less than the current time, delete operation
306 if timestamp < time.Now().Unix() {
307 _, err := ldb.HClear([]byte(args[1]))
308 if err != nil {
309 return nil, err
310 }
311 return redcon.SimpleInt(0), nil
312 }
313
314 v, err := ldb.HExpireAt([]byte(args[1]), timestamp)
315 if err != nil {
316 return nil, err
317 }
318 return redcon.SimpleInt(v), nil
319}
320

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected