Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (42 sloc) 1.398 kb
#
# Base Newscloud Sweeper; extend from this
#
class NewscloudSweeper < ActionController::Caching::Sweeper
def expire(item = nil) end
def expire_all(item = nil) end
def self.expire(item = nil) end
def self.expire_all(item = nil) end
def self.expire_class klass, namespace = nil
namespace ||= '*'
key = "#{klass.name.downcase}:view_object_namespace_deps:#{namespace}"
keys = $redis.keys(key)
#return $redis.sunion(*($redis.keys(key))).map {|vo_name| vo_name.split(/:/).inject(nil) {|m,id| m.nil? ? id.classify.constantize : m.find(id) } }
if keys.any?
$redis.sunion(*(keys)).each do |key_name|
if key_name =~ /^view_object:([0-9]+)$/
view_object = ViewObject.find_by_id($1)
view_object.uncache_deps if view_object
end
end
end
end
def self.expire_new_item_widgets
[Vote, PfeedItem, ItemAction, ItemScore].each do |klass|
self.expire_class(klass)
end
end
def self.expire_instance item
keys = $redis.keys(item.model_deps_key)
if keys.any?
$redis.sunion(item.model_deps_key).each do |key_name|
if key_name =~ /^view_object:([0-9]+)$/
view_object = ViewObject.find_by_id($1)
view_object.uncache_deps if view_object
end
end
end
# TODO:: stop this
self.expire_new_item_widgets
return self.expire_class(item.class)
end
end
Jump to Line
Something went wrong with that request. Please try again.