Class: DRb::TimerIdConv
Overview
Timer id conversion keeps objects alive for a certain amount of time after their last access. The default time period is 600 seconds and can be changed upon initialization.
To use TimerIdConv:
DRb.install_id_conv TimerIdConv.new 60 # one minute
Defined Under Namespace
Classes: TimerHolder2
Instance Method Summary collapse
-
#initialize(timeout = 600) ⇒ TimerIdConv
constructor
Creates a new TimerIdConv which will hold objects for
timeout
seconds. -
#to_id(obj) ⇒ Object
:nodoc:.
-
#to_obj(ref) ⇒ Object
:nodoc:.
Constructor Details
#initialize(timeout = 600) ⇒ TimerIdConv
Creates a new TimerIdConv which will hold objects for timeout
seconds.
85 86 87 |
# File 'lib/drb/timeridconv.rb', line 85 def initialize(timeout=600) @holder = TimerHolder2.new(timeout) end |
Instance Method Details
#to_id(obj) ⇒ Object
:nodoc:
96 97 98 |
# File 'lib/drb/timeridconv.rb', line 96 def to_id(obj) # :nodoc: return @holder.add(obj) end |
#to_obj(ref) ⇒ Object
:nodoc:
89 90 91 92 93 94 |
# File 'lib/drb/timeridconv.rb', line 89 def to_obj(ref) # :nodoc: return super if ref.nil? @holder.fetch(ref) rescue TimerHolder2::InvalidIndexError raise "invalid reference" end |