@@ -261,12 +261,8 @@ class ClusterCache {
261261 /**
262262 * Delete specific key from cache
263263 * @param {string } key - Cache key to delete
264- * @param {boolean } countAsInvalidation - Deprecated parameter (kept for backwards compatibility)
265264 */
266- async delete ( key , countAsInvalidation = false ) {
267- const startTime = Date . now ( )
268- const workerId = process . env . pm_id || process . pid
269-
265+ async delete ( key ) {
270266 try {
271267 // Only delete from cluster cache in PM2 mode to avoid IPC timeouts
272268 if ( this . isPM2 ) {
@@ -279,7 +275,6 @@ class ClusterCache {
279275 this . keySizes . delete ( key )
280276 this . totalBytes -= size
281277 this . localCache . delete ( key )
282- const duration = Date . now ( ) - startTime
283278 return true
284279 } catch ( err ) {
285280 this . localCache . delete ( key )
@@ -289,7 +284,6 @@ class ClusterCache {
289284 const size = this . keySizes . get ( key ) || 0
290285 this . keySizes . delete ( key )
291286 this . totalBytes -= size
292- const duration = Date . now ( ) - startTime
293287 return false
294288 }
295289 }
@@ -494,7 +488,7 @@ class ClusterCache {
494488 }
495489
496490 if ( regex . test ( key ) ) {
497- deletePromises . push ( this . delete ( key , true ) )
491+ deletePromises . push ( this . delete ( key ) )
498492 matchedKeys . push ( key )
499493 invalidatedKeys . add ( key )
500494 count ++
@@ -800,9 +794,6 @@ class ClusterCache {
800794 * @returns {Promise<number> } Number of cache entries invalidated
801795 */
802796 async invalidateByObject ( obj , invalidatedKeys = new Set ( ) ) {
803- const startTime = Date . now ( )
804- const workerId = process . env . pm_id || process . pid
805-
806797 if ( ! obj || typeof obj !== 'object' ) {
807798 return 0
808799 }
@@ -814,7 +805,6 @@ class ClusterCache {
814805 if ( this . isPM2 ) {
815806 try {
816807 // Scan all keys directly from cluster cache (all workers)
817- const clusterGetStart = Date . now ( )
818808 const keysMap = await this . clusterCache . keys ( )
819809 const uniqueKeys = new Set ( )
820810
@@ -830,7 +820,6 @@ class ClusterCache {
830820 }
831821
832822 keysToCheck = Array . from ( uniqueKeys )
833- const clusterGetDuration = Date . now ( ) - clusterGetStart
834823 } catch ( err ) {
835824 keysToCheck = Array . from ( this . allKeys ) . filter ( k =>
836825 k . startsWith ( 'query:' ) || k . startsWith ( 'search:' ) || k . startsWith ( 'searchPhrase:' )
@@ -881,7 +870,7 @@ class ClusterCache {
881870 const queryParams = JSON . parse ( queryJson )
882871
883872 if ( this . objectMatchesQuery ( obj , queryParams ) ) {
884- await this . delete ( cacheKey , true ) // Pass true to count this deletion
873+ await this . delete ( cacheKey )
885874 invalidatedKeys . add ( cacheKey )
886875 count ++
887876 }
@@ -891,8 +880,6 @@ class ClusterCache {
891880 }
892881 }
893882
894- const duration = Date . now ( ) - startTime
895-
896883 return count
897884 }
898885
0 commit comments