Change keyvalue.Get to return if a value exists or not instead of an error
This commit is contained in:
parent
fe72f30b24
commit
2e88600c93
9 changed files with 28 additions and 43 deletions
|
|
@ -44,16 +44,11 @@ func (s *Storage) Put(key string, value interface{}) (err error) {
|
|||
}
|
||||
|
||||
// Get retrieves a saved value from memory storage
|
||||
func (s *Storage) Get(key string) (value interface{}, err error) {
|
||||
func (s *Storage) Get(key string) (value interface{}, exists bool, err error) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
var exists bool
|
||||
value, exists = s.store[key]
|
||||
if !exists {
|
||||
return nil, &e.ErrValueNotFoundForKey{Key: key}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue