@@ -67,7 +67,7 @@ export class RedisQueryResultCache implements QueryResultCache {
6767
6868 await this . client . connect ( )
6969 } else if ( this . clientType === "ioredis" ) {
70- if ( cacheOptions && cacheOptions . port ) {
70+ if ( cacheOptions ? .port ) {
7171 if ( cacheOptions . options ) {
7272 this . client = new this . redis (
7373 cacheOptions . port ,
@@ -76,23 +76,15 @@ export class RedisQueryResultCache implements QueryResultCache {
7676 } else {
7777 this . client = new this . redis ( cacheOptions . port )
7878 }
79- } else if ( cacheOptions && cacheOptions . options ) {
79+ } else if ( cacheOptions ? .options ) {
8080 this . client = new this . redis ( cacheOptions . options )
8181 } else {
8282 this . client = new this . redis ( )
8383 }
8484 } else if ( this . clientType === "ioredis/cluster" ) {
85- if (
86- cacheOptions &&
87- cacheOptions . options &&
88- Array . isArray ( cacheOptions . options )
89- ) {
85+ if ( cacheOptions ?. options && Array . isArray ( cacheOptions . options ) ) {
9086 this . client = new this . redis . Cluster ( cacheOptions . options )
91- } else if (
92- cacheOptions &&
93- cacheOptions . options &&
94- cacheOptions . options . startupNodes
95- ) {
87+ } else if ( cacheOptions ?. options ?. startupNodes ) {
9688 this . client = new this . redis . Cluster (
9789 cacheOptions . options . startupNodes ,
9890 cacheOptions . options . options ,
@@ -133,7 +125,9 @@ export class RedisQueryResultCache implements QueryResultCache {
133125 options : QueryResultCacheOptions ,
134126 queryRunner ?: QueryRunner ,
135127 ) : Promise < QueryResultCacheOptions | undefined > {
136- const key = options . identifier || options . query
128+ const identifier =
129+ options . identifier === "" ? undefined : options . identifier
130+ const key = identifier ?? options . query
137131 if ( ! key ) return undefined
138132
139133 const result = await this . client . get ( key )
@@ -161,7 +155,9 @@ export class RedisQueryResultCache implements QueryResultCache {
161155 savedCache : QueryResultCacheOptions ,
162156 queryRunner ?: QueryRunner ,
163157 ) : Promise < void > {
164- const key = options . identifier || options . query
158+ const identifier =
159+ options . identifier === "" ? undefined : options . identifier
160+ const key = identifier ?? options . query
165161 if ( ! key ) return
166162
167163 const value = JSON . stringify ( options )
0 commit comments