Class: ActiveRecord::Bulkoperation::Util::SequenceCache
- Inherits:
-
Object
- Object
- ActiveRecord::Bulkoperation::Util::SequenceCache
- Defined in:
- lib/activerecord_bulkoperation/util/sequence_cache.rb
Instance Method Summary collapse
-
#initialize(seq, prefetch = 10) ⇒ SequenceCache
constructor
seq - the sequence name to use with the SequenceCache object refetch - how many values should be fetch from the database with each roundtrip.
-
#next_value ⇒ Object
return - the next value from the sequence.
Constructor Details
#initialize(seq, prefetch = 10) ⇒ SequenceCache
seq - the sequence name to use with the SequenceCache object refetch - how many values should be fetch from the database with each roundtrip
17 18 19 20 |
# File 'lib/activerecord_bulkoperation/util/sequence_cache.rb', line 17 def initialize(seq, prefetch = 10) @seq, @prefetch = seq, prefetch @queue = Queue.new end |
Instance Method Details
#next_value ⇒ Object
return - the next value from the sequence
24 25 26 27 28 29 |
# File 'lib/activerecord_bulkoperation/util/sequence_cache.rb', line 24 def next_value while ( value = next_value_from_queue ).nil? fill_queue end value end |