Module: CanvasSync::JobBatches::RedisModel
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/canvas_sync/job_batches/redis_model.rb
Instance Method Summary collapse
- #flush_pending_attrs ⇒ Object
- #persist_bid_attr(attribute, value) ⇒ Object
- #read_bid_attr(attribute) ⇒ Object
Instance Method Details
#flush_pending_attrs ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/canvas_sync/job_batches/redis_model.rb', line 59 def flush_pending_attrs redis do |r| r.mapped_hmset(redis_key, @pending_attrs) end @initialized = true @pending_attrs = {} end |
#persist_bid_attr(attribute, value) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/canvas_sync/job_batches/redis_model.rb', line 39 def persist_bid_attr(attribute, value) if @initialized || @existing redis do |r| r.multi do |r| r.hset(redis_key, attribute, value.to_s) r.expire(redis_key, Batch::BID_EXPIRE_TTL) end end else @pending_attrs ||= {} @pending_attrs[attribute] = value.to_s end end |
#read_bid_attr(attribute) ⇒ Object
53 54 55 56 57 |
# File 'lib/canvas_sync/job_batches/redis_model.rb', line 53 def read_bid_attr(attribute) redis do |r| r.hget(redis_key, attribute) end end |