mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
✏ return nil for notfound
This commit is contained in:
@@ -2,7 +2,6 @@ package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -14,10 +13,6 @@ type Storage struct {
|
||||
db *redis.Client
|
||||
}
|
||||
|
||||
// ErrNotFound means that a get call did not find the requested key.
|
||||
var ErrNotFound = errors.New("key not found")
|
||||
var ErrKeyNotExist = ErrNotFound
|
||||
|
||||
// New creates a new redis storage
|
||||
func New(config ...Config) *Storage {
|
||||
// Set default config
|
||||
@@ -52,11 +47,11 @@ func New(config ...Config) *Storage {
|
||||
// Get value by key
|
||||
func (s *Storage) Get(key string) ([]byte, error) {
|
||||
if len(key) <= 0 {
|
||||
return nil, ErrNotFound
|
||||
return nil, nil
|
||||
}
|
||||
val, err := s.db.Get(context.Background(), key).Bytes()
|
||||
if err == redis.Nil {
|
||||
return nil, ErrNotFound
|
||||
return nil, nil
|
||||
}
|
||||
return val, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user