@@ -761,6 +761,7 @@ export class QueryCache {
761761 useCsvQuery : options . useCsvQuery ,
762762 lambdaTypes : options . lambdaTypes ,
763763 persistent : options . persistent ,
764+ primaryQuery : true ,
764765 }
765766 ) ,
766767 refreshKeyValues : cacheKeyQueryResults ,
@@ -793,7 +794,6 @@ export class QueryCache {
793794 ) {
794795 return cacheKeyQueries . map ( ( q ) => {
795796 const [ query , values , queryOptions ] : QueryTuple = Array . isArray ( q ) ? q : [ q , [ ] , { } ] ;
796-
797797 return this . cacheQueryResult (
798798 query ,
799799 < string [ ] > values ,
@@ -836,11 +836,12 @@ export class QueryCache {
836836 useCsvQuery ?: boolean ,
837837 lambdaTypes ?: TableStructure ,
838838 persistent ?: boolean ,
839+ primaryQuery ?: boolean ,
839840 }
840841 ) {
841842 const spanId = crypto . randomBytes ( 16 ) . toString ( 'hex' ) ;
842843 options = options || { dataSource : 'default' } ;
843- const { renewalThreshold } = options ;
844+ const { renewalThreshold, primaryQuery } = options ;
844845 const renewalKey = options . renewalKey && this . queryRedisKey ( options . renewalKey ) ;
845846 const redisKey = this . queryRedisKey ( cacheKey ) ;
846847 const fetchNew = ( ) => (
@@ -864,7 +865,7 @@ export class QueryCache {
864865 . cacheDriver
865866 . set ( redisKey , result , expiration )
866867 . then ( ( { bytes } ) => {
867- this . logger ( 'Renewed' , { cacheKey, requestId : options . requestId , spanId } ) ;
868+ this . logger ( 'Renewed' , { cacheKey, requestId : options . requestId , spanId, primaryQuery } ) ;
868869 this . logger ( 'Outgoing network usage' , {
869870 service : 'cache' ,
870871 requestId : options . requestId ,
@@ -876,7 +877,7 @@ export class QueryCache {
876877 } ) ;
877878 } ) . catch ( e => {
878879 if ( ! ( e instanceof ContinueWaitError ) ) {
879- this . logger ( 'Dropping Cache' , { cacheKey, error : e . stack || e , requestId : options . requestId , spanId } ) ;
880+ this . logger ( 'Dropping Cache' , { cacheKey, error : e . stack || e , requestId : options . requestId , spanId, primaryQuery } ) ;
880881 this . cacheDriver . remove ( redisKey )
881882 . catch ( err => this . logger ( 'Error removing key' , {
882883 cacheKey,
@@ -890,7 +891,7 @@ export class QueryCache {
890891 ) ;
891892
892893 if ( options . forceNoCache ) {
893- this . logger ( 'Force no cache for' , { cacheKey, requestId : options . requestId , spanId } ) ;
894+ this . logger ( 'Force no cache for' , { cacheKey, requestId : options . requestId , spanId, primaryQuery } ) ;
894895 return fetchNew ( ) ;
895896 }
896897
@@ -924,6 +925,7 @@ export class QueryCache {
924925 renewalThreshold,
925926 requestId : options . requestId ,
926927 spanId,
928+ primaryQuery,
927929 } ) ;
928930 res = inMemoryValue ;
929931 }
@@ -946,6 +948,7 @@ export class QueryCache {
946948 renewalThreshold,
947949 requestId : options . requestId ,
948950 spanId,
951+ primaryQuery,
949952 } ) ;
950953 if (
951954 renewalKey && (
@@ -956,24 +959,24 @@ export class QueryCache {
956959 )
957960 ) {
958961 if ( options . waitForRenew ) {
959- this . logger ( 'Waiting for renew' , { cacheKey, renewalThreshold, requestId : options . requestId , spanId } ) ;
962+ this . logger ( 'Waiting for renew' , { cacheKey, renewalThreshold, requestId : options . requestId , spanId, primaryQuery } ) ;
960963 return fetchNew ( ) ;
961964 } else {
962- this . logger ( 'Renewing existing key' , { cacheKey, renewalThreshold, requestId : options . requestId , spanId } ) ;
965+ this . logger ( 'Renewing existing key' , { cacheKey, renewalThreshold, requestId : options . requestId , spanId, primaryQuery } ) ;
963966 fetchNew ( ) . catch ( e => {
964967 if ( ! ( e instanceof ContinueWaitError ) ) {
965- this . logger ( 'Error renewing' , { cacheKey, error : e . stack || e , requestId : options . requestId , spanId } ) ;
968+ this . logger ( 'Error renewing' , { cacheKey, error : e . stack || e , requestId : options . requestId , spanId, primaryQuery } ) ;
966969 }
967970 } ) ;
968971 }
969972 }
970- this . logger ( 'Using cache for' , { cacheKey, requestId : options . requestId , spanId } ) ;
973+ this . logger ( 'Using cache for' , { cacheKey, requestId : options . requestId , spanId, primaryQuery } ) ;
971974 if ( options . useInMemory && renewedAgo + inMemoryCacheDisablePeriod <= renewalThreshold * 1000 ) {
972975 this . memoryCache . set ( redisKey , parsedResult ) ;
973976 }
974977 return parsedResult . result ;
975978 } else {
976- this . logger ( 'Missing cache for' , { cacheKey, requestId : options . requestId , spanId } ) ;
979+ this . logger ( 'Missing cache for' , { cacheKey, requestId : options . requestId , spanId, primaryQuery } ) ;
977980 return fetchNew ( ) ;
978981 }
979982 }
0 commit comments