From b95697fe5db6ecb1e445a24b62a918ebc4949a5d Mon Sep 17 00:00:00 2001 From: Guillaume Clochard Date: Mon, 28 Aug 2023 21:01:56 +0200 Subject: [PATCH] add store id logic --- rss-to-tana/store.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rss-to-tana/store.js b/rss-to-tana/store.js index a2fcaa6..cffc836 100644 --- a/rss-to-tana/store.js +++ b/rss-to-tana/store.js @@ -8,6 +8,9 @@ const client = createClient({ client.on('error', error => console.error('Redis Client Error', error)); +// change the prefix to trash all existing ids +const toStoreId = (id) => `1-${id}` + const initialize = async () => { console.log('Connecting to Redis', REDIS_URL) await client.connect(); @@ -15,13 +18,13 @@ const initialize = async () => { } const savedAlready = async (itemId) => { - const nbKeysFound = await client.exists(itemId) + const nbKeysFound = await client.exists(toStoreId(itemId)) return nbKeysFound === 1 } const saveItemSaved = async (itemId) => { await client.set( - itemId, + toStoreId(itemId), 0, { EX: 345600, // 4 days in seconds