Skip to content

Commit

Permalink
Return nil, err in set() instead of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishforbes committed Jan 14, 2016
1 parent a8cd27d commit e128f4d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/resty/tlc/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function _M.set(self, key, value, ttl)
-- Save value
local success, err, forcible = self.dict:set(key, value, ttl, flags)
if not success then
ngx_log(ngx_ERR, "Error saving to shared dictionary for key '", key, "': ", err)
return nil, "Error saving to shared dictionary for key '"..key.."': "..err
end
if DEBUG then ngx_log(ngx_DEBUG, "Saved to dictionary") end

Expand All @@ -131,7 +131,7 @@ function _M.set(self, key, value, ttl)
local expires = ngx_time() + ttl
local success, err, forcible = self.dict:set(key.."|tlc_expires", expires, ttl)
if not success then
ngx_log(ngx_ERR, "Error saving expiry time to shared dictionary for key '", key, "': ", err)
return nil, "Error saving expiry time to shared dictionary for key '"..key.."': "..err
end
if DEBUG then ngx_log(ngx_DEBUG, "Saved expiry '", expires, "'' to shared dictionary") end
end
Expand Down

0 comments on commit e128f4d

Please sign in to comment.