lib/cache_harvester.rb
# Saves the item from the cache to the database
Saves the item from the cache to the database
Saves the item from the cache to the database
def save_from_cache(start=nil, stop=nil)
      if start.nil? || stop.nil?
        start = Rails.cache.read(index_min, :raw => true).to_i
        stop  = Rails.cache.read(index_max, :raw => true).to_i
      end
      t = start
      total = 0
      while t <= stop
        ck = cache_key_for_index(t)
        obj = load(ck)
        unless obj.nil?
          if obj.save!
            Rails.cache.delete(ck)
            total += 1
          end
        end
        t += 1
        Rails.cache.write(index_min, t, :raw => true)
      end
      total
    end
def save_from_cache ( start = nil , stop = nil ) if start . nil? || stop . nil? start = Rails . cache . read ( index_min , :raw => true ) . to_i stop = Rails . cache . read ( index_max , :raw => true ) . to_i end t = start total = 0 while t <= stop ck = cache_key_for_index ( t ) obj = load ( ck ) unless obj . nil? if obj . save! Rails . cache . delete ( ck ) total += 1 end end t += 1 Rails . cache . write ( index_min , t , :raw => true ) end total end
Saves the item from the cache to the database
Saves the item from the cache to the database
start
<not_specific>
stop
<not_specific>