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

Method decodeExpire

structure/expiring_key.go:195–221  ·  view source on GitHub ↗

decodeList decodes the value

(value []byte)

Source from the content-addressed store, hash-verified

193
194// decodeList decodes the value
195func (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
223func (ek *ExpireStructure) Stop() error {
224 err := ek.db.Close()

Callers 1

getExpireFromDBMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected