(key string)
| 44 | } |
| 45 | |
| 46 | func (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 | |
| 69 | func (ek *ExpireStructure) PTTL(key string) (int64, error) { |
| 70 | // Get the deadtime |
nothing calls this directly
no test coverage detected