redis-timeline
redis-timeline copied to clipboard
Clean activity on unfollow
Yes, this is needed.
Can you advice how i can add this options per actor
LTRIM
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
That looks like it will work
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