Use Rails.cache.fetch instead of read/write
parent
077478091a
commit
7208f28ebe
|
@ -14,11 +14,8 @@ module ProjectHoneypotRails
|
||||||
ip_address = request.remote_ip
|
ip_address = request.remote_ip
|
||||||
key = "httpbl_#{ip_address}"
|
key = "httpbl_#{ip_address}"
|
||||||
|
|
||||||
if Rails.cache.exist?(key)
|
safe = Rails.cache.fetch(key, expires_in: 6.hours) do
|
||||||
safe = Rails.cache.read(key)
|
::ProjectHoneypot.lookup(ip_address).safe?
|
||||||
else
|
|
||||||
safe = ::ProjectHoneypot.lookup(ip_address).safe?
|
|
||||||
Rails.cache.write(key, safe, expires_in: 6.hours)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_unverified_request unless safe
|
handle_unverified_request unless safe
|
||||||
|
|
Loading…
Reference in New Issue