Merge pull request #3459 from omnivore-app/fix/fallback-to-worker-redis
fallback to worker redis client if fetched content not found in cache
This commit is contained in:
@ -139,13 +139,18 @@ const sendImportStatusUpdate = async (
|
||||
|
||||
const getCachedFetchResult = async (url: string) => {
|
||||
const key = `fetch-result:${url}`
|
||||
if (!redisDataSource.redisClient) {
|
||||
if (!redisDataSource.redisClient || !redisDataSource.workerRedisClient) {
|
||||
throw new Error('redis client is not initialized')
|
||||
}
|
||||
|
||||
const result = await redisDataSource.redisClient.get(key)
|
||||
let result = await redisDataSource.redisClient.get(key)
|
||||
if (!result) {
|
||||
throw new Error('fetch result is not cached')
|
||||
logger.debug(`fetch result is not cached in cache redis ${url}`)
|
||||
// fallback to worker redis client if the result is not found
|
||||
result = await redisDataSource.workerRedisClient.get(key)
|
||||
if (!result) {
|
||||
throw new Error('fetch result is not cached')
|
||||
}
|
||||
}
|
||||
|
||||
const fetchResult = JSON.parse(result) as unknown
|
||||
|
||||
Reference in New Issue
Block a user