✏ update comments

This commit is contained in:
Fenny
2020-11-17 13:56:09 +01:00
parent deb10fb2a7
commit ddef41c2ee
28 changed files with 173 additions and 99 deletions

View File

@@ -14,8 +14,8 @@ type Storage struct {
db *redis.Client
}
// Common storage errors
var ErrNotExist = errors.New("key does not exist")
// ErrNotFound means that a get call did not find the requested key.
var ErrNotFound = errors.New("key not found")
// New creates a new redis storage
func New(config ...Config) *Storage {
@@ -51,11 +51,11 @@ func New(config ...Config) *Storage {
// Get value by key
func (s *Storage) Get(key string) ([]byte, error) {
if len(key) <= 0 {
return nil, ErrNotExist
return nil, ErrNotFound
}
val, err := s.db.Get(context.Background(), key).Bytes()
if err == redis.Nil {
return nil, ErrNotExist
return nil, ErrNotFound
}
return val, err
}