| 67 | } |
| 68 | |
| 69 | func (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 | |
| 90 | func (ek *ExpireStructure) PERSIST(key string, seconds int64) error { |
| 91 | return ek.setExpireToDB(key, -1) |