Module: RedisPage::ViewHelpers
- Defined in:
- lib/redis_page/view_helpers.rb
Instance Method Summary collapse
-
#c(object) ⇒ Object
记录当前实体相关的页面,方便实体更新时,刷新页面缓存.
-
#mark_cache_instance(*array) ⇒ Object
记录当前实体相关的页面,方便实体更新时,刷新页面缓存 1.
Instance Method Details
#c(object) ⇒ Object
记录当前实体相关的页面,方便实体更新时,刷新页面缓存
5 6 7 8 |
# File 'lib/redis_page/view_helpers.rb', line 5 def c(object) mark_cache_instance(object) if @page_need_to_cache object end |
#mark_cache_instance(*array) ⇒ Object
记录当前实体相关的页面,方便实体更新时,刷新页面缓存
-
object 直接传递实体对象
-
name, id 或者传递实体表名及id
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/redis_page/view_helpers.rb', line 14 def mark_cache_instance(*array) name, id = array object = array.first if id name = name.downcase else name = object.class.table_name.downcase id = object.id end Rails.logger.info "[page cache]record: #{name}##{id}" RedisPage.redis.sadd("i:#{name}:#{id}", { url: request.url, country: @cache_country }.to_json) end |