mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 21:27:16 -05:00
This commit is contained in:
@@ -25,6 +25,8 @@ module Discourse
|
||||
# When ImageMagick is missing
|
||||
class ImageMagickMissing < Exception; end
|
||||
|
||||
class InvalidPost < Exception; end
|
||||
|
||||
# Cross site request forgery
|
||||
class CSRF < Exception; end
|
||||
|
||||
|
||||
+17
-10
@@ -15,18 +15,25 @@ class DistributedMemoizer
|
||||
|
||||
start = Time.new
|
||||
got_lock = false
|
||||
while Time.new < start + MAX_WAIT && !got_lock
|
||||
LOCK.synchronize do
|
||||
got_lock = get_lock(redis,redis_lock_key)
|
||||
end
|
||||
sleep 0.001
|
||||
end
|
||||
|
||||
unless result = redis.get(redis_key)
|
||||
result = yield
|
||||
redis.setex(redis_key, duration, result)
|
||||
begin
|
||||
while Time.new < start + MAX_WAIT && !got_lock
|
||||
LOCK.synchronize do
|
||||
got_lock = get_lock(redis,redis_lock_key)
|
||||
end
|
||||
sleep 0.001
|
||||
end
|
||||
|
||||
unless result = redis.get(redis_key)
|
||||
result = yield
|
||||
redis.setex(redis_key, duration, result)
|
||||
end
|
||||
|
||||
ensure
|
||||
# NOTE: delete regardless so next one in does not need to wait MAX_WAIT
|
||||
# again
|
||||
redis.del(redis_lock_key)
|
||||
end
|
||||
redis.del(redis_lock_key)
|
||||
end
|
||||
|
||||
result
|
||||
|
||||
Reference in New Issue
Block a user