Skip to content

Commit

Permalink
add store id logic
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumewuip committed Aug 28, 2023
1 parent 3908ff0 commit b95697f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rss-to-tana/store.js
Expand Up @@ -8,20 +8,23 @@ 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();
console.log('Connected!')
}

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
Expand Down

0 comments on commit b95697f

Please sign in to comment.