decodeList decodes the value
(value []byte)
| 193 | |
| 194 | // decodeList decodes the value |
| 195 | func (ek *ExpireStructure) decodeExpire(value []byte) (int64, error) { |
| 196 | // Check the length of the value |
| 197 | if len(value) < 1 { |
| 198 | return 0, ErrInvalidValue |
| 199 | } |
| 200 | |
| 201 | // Check the type of the value |
| 202 | if value[0] != Expire { |
| 203 | return 0, ErrInvalidType |
| 204 | } |
| 205 | |
| 206 | // Use the variable bufIndex to keep track of the current index position in value, |
| 207 | // starting from 1 to indicate the number of bytes read so far. |
| 208 | var bufIndex = 1 |
| 209 | |
| 210 | // Decode the expiration time expire from the sub-slice of byte slice value |
| 211 | // starting from the current index position bufIndex. |
| 212 | deadtime, n := binary.Varint(value[bufIndex:]) |
| 213 | |
| 214 | // Check the number of bytes read |
| 215 | if n <= 0 { |
| 216 | return 0, ErrInvalidValue |
| 217 | } |
| 218 | |
| 219 | // Return the original value value |
| 220 | return deadtime, nil |
| 221 | } |
| 222 | |
| 223 | func (ek *ExpireStructure) Stop() error { |
| 224 | err := ek.db.Close() |