redis-timeline icon indicating copy to clipboard operation
redis-timeline copied to clipboard

Clean activity on unfollow

Open huacnlee opened this issue 12 years ago • 5 comments

huacnlee avatar May 02 '12 09:05 huacnlee

Yes, this is needed.

felixclack avatar Jun 08 '12 23:06 felixclack

Can you advice how i can add this options per actor

LTRIM 0 99 EXPIRE 3600

bublik avatar Nov 02 '15 14:11 bublik

 def timeline_clear
    Timeline.redis.del("user:id:#{self.id}:activity")
  end

  def timeline_expite_set(seconds = 7.days.to_i)
    Timeline.redis.expire("user:id:#{self.id}:activity", seconds)
  end

  def timeline_page(page = 1, per_page = 20)
    page ||=1
    start_item = (page - 1) * per_page
    end_item = page * per_page - 1
    timeline(start: start_item, end: end_item)
  end

bublik avatar Nov 05 '15 10:11 bublik

That looks like it will work

felixclack avatar Nov 09 '15 02:11 felixclack

What do you think We are calling redis_add many times in different places

    def add_activity(activity_item)
      redis_add "global:activity", activity_item
      add_activity_to_user(activity_item[:actor][:id], activity_item)
      add_activity_by_user(activity_item[:actor][:id], activity_item)
      add_mentions(activity_item)
      add_activity_to_followers(activity_item) if @followers.any?
    end

and doing JSON encode for every one follower i think will be simple prepare json string and use string instead object and many times do encode

def redis_add(list, activity_item)
      Timeline.redis.lpush list, Timeline.encode(activity_item)
end

bublik avatar Nov 09 '15 09:11 bublik