lib/rodauth/oauth/ttl_store.rb in rodauth-oauth-1.0.0.pre.beta1 vs lib/rodauth/oauth/ttl_store.rb in rodauth-oauth-1.0.0.pre.beta2
- old
+ new
@@ -26,9 +26,11 @@
return @store[key][:payload] if @store[key] && @store[key][:ttl] < now
end
payload, ttl = block.call
+ return payload unless ttl
+
@store_mutex.synchronize do
# given that the block call triggers network, and two requests for the same key be processed
# at the same time, this ensures the first one wins.
return @store[key][:payload] if @store[key] && @store[key][:ttl] < now