From 499a9a406f2dba84ef33e7646d9a2170be5889e6 Mon Sep 17 00:00:00 2001 From: Dheeraj Manjunath Date: Tue, 27 Dec 2022 13:00:44 -0500 Subject: [PATCH] Periodically add blacklisted items to redis (#4532) * Periodically add to redis * Add log * Change to 1 hour for testing * Convert to arrow fn * Adjust interval --- creator-node/src/blacklistManager.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/creator-node/src/blacklistManager.js b/creator-node/src/blacklistManager.js index 4dd0d59bca0..b248839ac0a 100644 --- a/creator-node/src/blacklistManager.js +++ b/creator-node/src/blacklistManager.js @@ -41,6 +41,21 @@ class BlacklistManager { userIdsToBlacklist, segmentsToBlacklist }) + + // add items to redis periodically in case redis restarts + setInterval(async () => { + const { + trackIdsToBlacklist, + userIdsToBlacklist, + segmentsToBlacklist + } = await this._getDataToBlacklist() + await this._fetchCIDsAndAddToRedis({ + trackIdsToBlacklist, + userIdsToBlacklist, + segmentsToBlacklist + }) + this._log(`Re-added to redis`) + }, 1000 * 60 * 60 * 2 /* two hours */) } this.initialized = true