Skip to content

Commit 7a48679

Browse files
fix: hash structured query for LRU cache
1 parent ff23493 commit 7a48679

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/modules/firebase/firestore/server.firebase.fs.service.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
makeFirestoreStateTransferKey,
2626
constructFsUrl
2727
} from './server.firebase.fs.common'
28+
import { sha1 } from 'object-hash'
2829

2930
interface Field {
3031
readonly [key: string]: any
@@ -197,9 +198,6 @@ export class ServerUniversalFirestoreService
197198
universalCollection<T>(path: string, queryFn?: QueryFn) {
198199
const url = constructFsUrl(extractFsHostFromLib(this.afs), undefined, true)
199200
const tsKey = makeFirestoreStateTransferKey(url)
200-
const params = getParams()
201-
const cacheKey = getFullUrl(url, params)
202-
const cachedValue = attemptToGetLruCachedValue<T>(cacheKey, this.lru)
203201
const ref = this.afs.firestore.collection(path)
204202
const query = (queryFn && queryFn(ref as any)) || ref
205203
const limit = (query as any)._query.limit
@@ -209,7 +207,8 @@ export class ServerUniversalFirestoreService
209207
const orderBy = (query as any)._query.explicitOrderBy as ReadonlyArray<
210208
OrderBy
211209
>
212-
210+
const cacheKey = sha1({ ...(query as any)._query, path })
211+
const cachedValue = attemptToGetLruCachedValue<T>(cacheKey, this.lru)
213212
const fieldFilters = filters.map(mapFilterToFieldFilter)
214213
const where = composeFilter(fieldFilters)
215214

0 commit comments

Comments
 (0)