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

Method PTTL

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

Source from the content-addressed store, hash-verified

67}
68
69func (ek *ExpireStructure) PTTL(key string) (int64, error) {
70 // Get the deadtime
71 deadtime, err := ek.getExpireFromDB(key, false)
72 if err != nil {
73 return 0, err
74 }
75 //key not exists
76 if deadtime == -2 {
77 return -2, nil
78 }
79 //forever
80 if deadtime == -1 {
81 return -1, nil
82 }
83 result := deadtime - ek.getCurrentMiliUnixTimeStamp()
84 if result <= 0 {
85 return -2, nil
86 }
87 return result, nil
88}
89
90func (ek *ExpireStructure) PERSIST(key string, seconds int64) error {
91 return ek.setExpireToDB(key, -1)

Callers 1

TestExpireStructure_PTTLFunction · 0.80

Calls 2

getExpireFromDBMethod · 0.95

Tested by 1

TestExpireStructure_PTTLFunction · 0.64