lib/models/nitro_partial.rb
# prerender will not start with rails, because it may need large amount of time
prerender will not start with rails, because it may need large amount of time
prerender will not start with rails because it may need large amount of time
def add_prerendered_partial( options )
      existing_partial = partials_cache[options[:partial]] || where( partial: options[:partial] ).first
      key_combinations = options[:key_combinations] || all_key_combinations( options[:all_locals], options[:partial] )
      partials_scopes[options[:partial]] = options[:scope]
      raise( ArgumentError, 'expires params must be in form: N.(day[s]|week[s]|month[s]|year[s]).from_now' ) if !options[:expires].blank? || EXPIRES_REGEX === options[:expires].to_s
      raise( ArgumentError, 'must have scope for prerendering' ) unless options[:scope]
      if existing_partial
        existing_partial.nitro_caches.where.not( nitro_cache_key: key_combinations.keys ).delete_all
        existing_partial.update_attributes(
            render_as: options[:as],
            cache_keys: key_combinations,
            expires: options[:expires].to_s,
            prerender: true )
        existing_partial
      else
        partials_cache[options[:partial]] = create(
            cache_keys: key_combinations,
            expires: options[:expires].to_s,
            prerender: true,
            render_as: options[:as],
            partial: options[:partial],
            partial_hash: partial_hash( options[:partial] ) )
      end
    end
def add_prerendered_partial ( options ) existing_partial = partials_cache [ options [ :partial ] ] || where ( partial : options [ :partial ] ) . first key_combinations = options [ :key_combinations ] || all_key_combinations ( options [ :all_locals ] , options [ :partial ] ) partials_scopes [ options [ :partial ] ] = options [ :scope ] raise ( ArgumentError , 'expires params must be in form: N.(day[s]|week[s]|month[s]|year[s]).from_now' ) if ! options [ :expires ] . blank? || EXPIRES_REGEX === options [ :expires ] . to_s raise ( ArgumentError , 'must have scope for prerendering' ) unless options [ :scope ] if existing_partial existing_partial . nitro_caches . where . not ( nitro_cache_key : key_combinations . keys ) . delete_all existing_partial . update_attributes ( render_as : options [ :as ] , cache_keys : key_combinations , expires : options [ :expires ] . to_s , prerender : true ) existing_partial else partials_cache [ options [ :partial ] ] = create ( cache_keys : key_combinations , expires : options [ :expires ] . to_s , prerender : true , render_as : options [ :as ] , partial : options [ :partial ] , partial_hash : partial_hash ( options [ :partial ] ) ) end end
prerender will not start with rails, because it may need large amount of time
prerender will not start with rails because it may need large amount of time
# all non existed now key combination will be deleted
options