MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TTL

Method TTL

structure/expiring_key.go:46–67  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

44}
45
46func (ek *ExpireStructure) TTL(key string) (int64, error) {
47 // Get the deadtime
48 deadtime, err := ek.getExpireFromDB(key, false)
49 if err != nil {
50 return 0, err
51 }
52 //key not exists
53 if deadtime == -2 {
54 return -2, nil
55 }
56
57 //forever
58 if deadtime == -1 {
59 return -1, nil
60 }
61
62 result := (deadtime - ek.getCurrentMiliUnixTimeStamp()) / 1000
63 if result <= 0 {
64 return -2, nil
65 }
66 return result, nil
67}
68
69func (ek *ExpireStructure) PTTL(key string) (int64, error) {
70 // Get the deadtime

Callers

nothing calls this directly

Calls 2

getExpireFromDBMethod · 0.95

Tested by

no test coverage detected