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
60 61 62 63 64 65 66 |
# File 'lib/canvas_sync/job_batches/redis_model.rb', line 60 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
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/canvas_sync/job_batches/redis_model.rb', line 40 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
54 55 56 57 58 |
# File 'lib/canvas_sync/job_batches/redis_model.rb', line 54 def read_bid_attr(attribute) redis do |r| r.hget(redis_key, attribute) end end |