mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fix: overriding caching settings when alwaysEnabled is true (#9731)
* 9023-2 Fix cache overriding option * 9023-2 Fix format
This commit is contained in:
parent
ef64bfc6c5
commit
4df969ea62
@ -3685,11 +3685,13 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
: {}
|
||||
let savedQueryResultCacheOptions: QueryResultCacheOptions | undefined =
|
||||
undefined
|
||||
const isCachingEnabled =
|
||||
// Caching is enabled globally and isn't disabled locally.
|
||||
(cacheOptions.alwaysEnabled && this.expressionMap.cache) ||
|
||||
// ...or it's enabled locally explicitly.
|
||||
this.expressionMap.cache
|
||||
let cacheError = false
|
||||
if (
|
||||
this.connection.queryResultCache &&
|
||||
(this.expressionMap.cache || cacheOptions.alwaysEnabled)
|
||||
) {
|
||||
if (this.connection.queryResultCache && isCachingEnabled) {
|
||||
try {
|
||||
savedQueryResultCacheOptions =
|
||||
await this.connection.queryResultCache.getFromCache(
|
||||
@ -3724,7 +3726,7 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
if (
|
||||
!cacheError &&
|
||||
this.connection.queryResultCache &&
|
||||
(this.expressionMap.cache || cacheOptions.alwaysEnabled)
|
||||
isCachingEnabled
|
||||
) {
|
||||
try {
|
||||
await this.connection.queryResultCache.storeInCache(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user