From 57250ade6361470753880e4e754cf231ab34d57e Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Tue, 12 Nov 2019 13:39:50 -0600 Subject: [PATCH] Expire Frequently Updated Cache Keys Sooner (#4793) [deploy] --- app/models/user.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 878c15043..d7db81462 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -241,8 +241,8 @@ class User < ApplicationRecord def cached_following_users_ids RedisRailsCache.fetch( - "user-#{id}-#{updated_at}-#{following_users_count}/following_users_ids", - expires_in: 120.hours, + "user-#{id}-#{last_followed_at}-#{following_users_count}/following_users_ids", + expires_in: 12.hours, ) do Follow.where(follower_id: id, followable_type: "User").limit(150).pluck(:followable_id) end @@ -250,8 +250,8 @@ class User < ApplicationRecord def cached_following_organizations_ids RedisRailsCache.fetch( - "user-#{id}-#{updated_at}-#{following_orgs_count}/following_organizations_ids", - expires_in: 120.hours, + "user-#{id}-#{last_followed_at}-#{following_orgs_count}/following_organizations_ids", + expires_in: 12.hours, ) do Follow.where(follower_id: id, followable_type: "Organization").limit(150).pluck(:followable_id) end @@ -259,8 +259,8 @@ class User < ApplicationRecord def cached_following_podcasts_ids RedisRailsCache.fetch( - "user-#{id}-#{updated_at}-#{last_followed_at}/following_podcasts_ids", - expires_in: 120.hours, + "user-#{id}-#{last_followed_at}/following_podcasts_ids", + expires_in: 12.hours, ) do Follow.where(follower_id: id, followable_type: "Podcast").pluck(:followable_id) end