lib/once.rb in once-0.0.4 vs lib/once.rb in once-0.1.0

- old
+ new

@@ -36,10 +36,15 @@ def do(name:, params:, within: DEFAULT_TIME, &block) hash = Digest::MD5.hexdigest(params.inspect) redis_key = "uniquecheck:#{name}:#{hash}" if redis.set(redis_key, true, ex: within, nx: true) - block.call + begin + block.call + rescue + redis.expire(redis_key, 0) + raise + end end end end end