mirror of
https://github.com/gofiber/storage.git
synced 2025-10-30 03:12:53 +08:00
Make Get return nil instead of []byte{}
This commit is contained in:
@@ -85,7 +85,7 @@ func (s *Storage) Get(key string) ([]byte, error) {
|
|||||||
|
|
||||||
// If the expiration time has already passed, then return nil
|
// If the expiration time has already passed, then return nil
|
||||||
if time.Now().After(time.Unix(exp, 0)) {
|
if time.Now().After(time.Unix(exp, 0)) {
|
||||||
return []byte{}, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return data, nil
|
return data, nil
|
||||||
|
|||||||
@@ -37,5 +37,5 @@ func Test_Expiration(t *testing.T) {
|
|||||||
|
|
||||||
b, err := s.Get("fiber-20k-stars?")
|
b, err := s.Get("fiber-20k-stars?")
|
||||||
utils.AssertEqual(t, nil, err)
|
utils.AssertEqual(t, nil, err)
|
||||||
utils.AssertEqual(t, []byte{}, b)
|
utils.AssertEqual(t, true, b == nil)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user