Class: MailRoom::Arbitration::Redis
- Inherits:
-
Object
- Object
- MailRoom::Arbitration::Redis
- Defined in:
- lib/mail_room/arbitration/redis.rb
Defined Under Namespace
Classes: Options
Constant Summary collapse
- EXPIRATION =
Expire after 10 minutes so Redis doesn’t get filled up with outdated data.
600
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #deliver?(uid, expiration = EXPIRATION) ⇒ Boolean
-
#initialize(options) ⇒ Redis
constructor
A new instance of Redis.
Constructor Details
#initialize(options) ⇒ Redis
Returns a new instance of Redis.
30 31 32 |
# File 'lib/mail_room/arbitration/redis.rb', line 30 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
28 29 30 |
# File 'lib/mail_room/arbitration/redis.rb', line 28 def @options end |
Instance Method Details
#deliver?(uid, expiration = EXPIRATION) ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mail_room/arbitration/redis.rb', line 34 def deliver?(uid, expiration = EXPIRATION) key = "delivered:#{uid}" # Set the key, but only if it doesn't already exist; # the return value is true if successful, false if the key was already set, # which is conveniently the correct return value for this method # Any subsequent failure in the instance which gets the lock will be dealt # with by the expiration, at which time another instance can pick up the # message and try again. client.set(key, 1, nx: true, ex: expiration) end |