mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
hash args in the cache key
This commit is contained in:
parent
c2ec95845e
commit
d00a76ca3f
1 changed files with 4 additions and 1 deletions
|
|
@ -35,6 +35,7 @@ import { logger } from '../utils/logger'
|
|||
import { parseSearchQuery } from '../utils/search'
|
||||
import { HighlightEvent } from './highlights'
|
||||
import { addLabelsToLibraryItem, LabelEvent } from './labels'
|
||||
import { stringToHash } from '../utils/helpers'
|
||||
|
||||
const columnsToDelete = [
|
||||
'user',
|
||||
|
|
@ -704,7 +705,9 @@ export const createSearchQueryBuilder = (
|
|||
}
|
||||
|
||||
export const countLibraryItems = async (args: SearchArgs, userId: string) => {
|
||||
const cacheKey = `countLibraryItems:${userId}:${JSON.stringify(args)}`
|
||||
// hash the arguments to create a unique cache key
|
||||
const argsHash = stringToHash(JSON.stringify(args))
|
||||
const cacheKey = `countLibraryItems:${userId}:${argsHash}`
|
||||
const cachedCount = await redisDataSource.redisClient?.get(cacheKey)
|
||||
if (cachedCount) {
|
||||
return parseInt(cachedCount, 10)
|
||||
|
|
|
|||
Loading…
Reference in a new issue