returns value int64 format by given key if non-existed or expired, return 0.
(key string)
| 90 | // returns value int64 format by given key |
| 91 | // if non-existed or expired, return 0. |
| 92 | func (ca *RuntimeCache) GetInt64(key string) (int64, error) { |
| 93 | v, err := ca.GetString(key) |
| 94 | if err != nil || v == "" { |
| 95 | return ZeroInt64, nil |
| 96 | } else { |
| 97 | i, e := strconv.ParseInt(v, 10, 64) |
| 98 | if e != nil { |
| 99 | return ZeroInt64, e |
| 100 | } else { |
| 101 | return i, nil |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | // Set cache to runtime. |
| 107 | // ttl is second, if ttl is 0, it will be forever till restart. |