lib/cache/live_updates_enabled.rb
def notify_if_feed_changed(feed, key)
        last_modified = get_last_modified key
        old_hash = last_modified ? last_modified[:hash] : ""
        last_modified[:hash] = Digest::SHA1.hexdigest(feed.to_json)

        # has content changed? if so, save last_modified to cache and trigger a message
        logger.debug "old = #{old_hash}, last = #{last_modified}"
        if old_hash != last_modified[:hash]
          last_modified[:timestamp] = format_date(Time.now.to_datetime)
          Rails.cache.write(last_modified_cache_key(key), last_modified, :expires_in => 28.days)
          Rails.cache.fetch(feed_changed_rate_limiter(key), :expires_in => 10.seconds) do
            Messaging.publish('/queues/feed_changed', key)
            true
          end
        end
        last_modified
      end
# Decorate the basic feed with Live Updates metadata.
Decorate the basic feed with Live Updates metadata.
Decorate the basic feed with Live Updates metadata .
def notify_if_feed_changed(feed, key)
        last_modified = get_last_modified key
        old_hash = last_modified ? last_modified[:hash] : ""
        last_modified[:hash] = Digest::SHA1.hexdigest(feed.to_json)
        logger.debug "old = #{old_hash}, last = #{last_modified}"
        if old_hash != last_modified[:hash]
          last_modified[:timestamp] = format_date(Time.now.to_datetime)
          Rails.cache.write(last_modified_cache_key(key), last_modified, :expires_in => 28.days)
          Rails.cache.fetch(feed_changed_rate_limiter(key), :expires_in => 10.seconds) do
            Messaging.publish('/queues/feed_changed', key)
            true
          end
        end
        last_modified
      end
def notify_if_feed_changed ( feed , key ) last_modified = get_last_modified key old_hash = last_modified ? last_modified [ :hash ] : "" last_modified [ :hash ] = Digest :: SHA1 . hexdigest ( feed . to_json ) logger . debug "old = #{old_hash}, last = #{last_modified}" if old_hash != last_modified [ :hash ] last_modified [ :timestamp ] = format_date ( Time . now . to_datetime ) Rails . cache . write ( last_modified_cache_key ( key ) , last_modified , :expires_in => 28 . days ) Rails . cache . fetch ( feed_changed_rate_limiter ( key ) , :expires_in => 10 . seconds ) do Messaging . publish ( '/queues/feed_changed' , key ) true end end last_modified end
Decorate the basic feed with Live Updates metadata.
Decorate the basic feed with Live Updates metadata .
# has content changed? if so, save last_modified to cache and trigger a message
feed
key