Class: Taskinator::Persistence::RedisCleanupVisitor
- Inherits:
-
Visitor::Base
- Object
- Visitor::Base
- Taskinator::Persistence::RedisCleanupVisitor
- Defined in:
- lib/taskinator/persistence.rb
Instance Attribute Summary collapse
-
#expire_in ⇒ Object
readonly
seconds.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
Instance Method Summary collapse
-
#initialize(conn, instance, expire_in) ⇒ RedisCleanupVisitor
constructor
A new instance of RedisCleanupVisitor.
- #visit ⇒ Object
- #visit_process(attribute) ⇒ Object
- #visit_tasks(tasks) ⇒ Object
Methods inherited from Visitor::Base
#task_count, #visit_args, #visit_attribute, #visit_attribute_enum, #visit_attribute_time, #visit_process_reference, #visit_task_reference, #visit_type
Constructor Details
#initialize(conn, instance, expire_in) ⇒ RedisCleanupVisitor
Returns a new instance of RedisCleanupVisitor.
636 637 638 639 640 641 |
# File 'lib/taskinator/persistence.rb', line 636 def initialize(conn, instance, expire_in) @conn = conn @instance = instance @expire_in = expire_in.to_i @key = instance.key end |
Instance Attribute Details
#expire_in ⇒ Object (readonly)
seconds
634 635 636 |
# File 'lib/taskinator/persistence.rb', line 634 def expire_in @expire_in end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
633 634 635 |
# File 'lib/taskinator/persistence.rb', line 633 def instance @instance end |
Instance Method Details
#visit ⇒ Object
643 644 645 646 |
# File 'lib/taskinator/persistence.rb', line 643 def visit @instance.accept(self) @conn.expire(@key, expire_in) end |
#visit_process(attribute) ⇒ Object
648 649 650 651 |
# File 'lib/taskinator/persistence.rb', line 648 def visit_process(attribute) process = @instance.send(attribute) RedisCleanupVisitor.new(@conn, process, expire_in).visit if process end |
#visit_tasks(tasks) ⇒ Object
653 654 655 656 657 658 659 660 |
# File 'lib/taskinator/persistence.rb', line 653 def visit_tasks(tasks) @conn.expire "#{@key}:tasks", expire_in @conn.expire "#{@key}.count", expire_in @conn.expire "#{@key}.pending", expire_in tasks.each do |task| RedisCleanupVisitor.new(@conn, task, expire_in).visit end end |