MS SM save sync cache if you have some sort of contacts
This commit is contained in:
parent
0f19076b40
commit
fe3fe0f5cc
2 changed files with 10 additions and 3 deletions
|
|
@ -28,7 +28,11 @@ module Diaspora
|
|||
if use_cache?(opts)
|
||||
cache = RedisCache.new(self, opts[:order_field])
|
||||
|
||||
#cache.ensure_populated!(opts)
|
||||
#total hax
|
||||
if self.contacts.where(:sharing => true, :receiving => true).count > 0
|
||||
cache.ensure_populated!(opts)
|
||||
end
|
||||
|
||||
name = klass.to_s.downcase
|
||||
shareable_ids = cache.send(name+"_ids", opts[:max_time], opts[:limit] +1)
|
||||
end
|
||||
|
|
@ -159,6 +163,7 @@ module Diaspora
|
|||
|
||||
protected
|
||||
# @return [Boolean]
|
||||
|
||||
def use_cache?(opts)
|
||||
RedisCache.configured? && RedisCache.supported_order?(opts[:order_field]) && opts[:all_aspects?].present?
|
||||
end
|
||||
|
|
|
|||
|
|
@ -102,8 +102,10 @@ describe User do
|
|||
AppConfig[:redis_cache] = nil
|
||||
end
|
||||
|
||||
it "kicks off a job that will populate the latest 100 posts" do
|
||||
pending "we need a job for this - ensure_populated! is too costly to do synchronously for new users"
|
||||
it "populates the cache if the user has a mutual contact" do
|
||||
RedisCache.any_instance.should_receive(:ensure_populated!)
|
||||
alice.stub(:use_cache?).and_return(true)
|
||||
alice.visible_shareable_ids(Post)
|
||||
end
|
||||
|
||||
it 'does not get used if if all_aspects? option is not present' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue