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

Method getExpireFromDB

structure/expiring_key.go:140–159  ·  view source on GitHub ↗

getExpireFromDB retrieves data from the database.

(key string, isKeyCanNotExist bool)

Source from the content-addressed store, hash-verified

138
139// getExpireFromDB retrieves data from the database.
140func (ek *ExpireStructure) getExpireFromDB(key string, isKeyCanNotExist bool) (int64, error) {
141 // Get data corresponding to the key from the database
142 dbData, err := ek.db.Get([]byte(key))
143
144 // Since the key might not exist, we need to handle ErrKeyNotFound separately as it is a valid case
145 if err != nil && err != _const.ErrKeyNotFound {
146 return 0, err
147 }
148
149 // Deserialize the data into a list
150 deadtime, err := ek.decodeExpire(dbData)
151 if err != nil {
152 if len(dbData) != 0 {
153 return 0, err
154 } else {
155 deadtime = -2
156 }
157 }
158 return deadtime, nil
159}
160
161// setExpireToDB stores the data into the database.
162func (ek *ExpireStructure) setExpireToDB(key string, deadtime int64) error {

Callers 2

TTLMethod · 0.95
PTTLMethod · 0.95

Calls 2

decodeExpireMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected