-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat : added redis * Feat : added redis retry
- Loading branch information
1 parent
1b4c1b3
commit c519505
Showing
11 changed files
with
430 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Redis from "ioredis"; | ||
import config from "../config"; | ||
|
||
const redis = new Redis({ | ||
host: config.host.redisHost, | ||
port: parseInt(config.cacheValues.redisPort), | ||
retryStrategy(times) { | ||
if (times > 1) { | ||
return null; // Stop retrying after one attempt | ||
} | ||
return 500; // Delay before retrying (in milliseconds) | ||
}, | ||
maxRetriesPerRequest: 1, // Allow only 1 retry per request | ||
reconnectOnError(err) { | ||
return false; // Do not reconnect on errors | ||
}, | ||
}); | ||
|
||
async function checkRedisConnection(): Promise<boolean> { | ||
try { | ||
await redis.ping(); | ||
return true; | ||
} catch (error) { | ||
console.error("Redis connection error:", error); | ||
return false; | ||
} | ||
} | ||
|
||
export { redis, checkRedisConnection }; |
Oops, something went wrong.