@@ -267,8 +267,6 @@ const cacheSince = (req, res, next) => {
267267 * Invalidates cache entries when objects are created, updated, or deleted
268268 */
269269const invalidateCache = ( req , res , next ) => {
270- console . log ( `[CACHE INVALIDATE] Middleware triggered for ${ req . method } ${ req . path } ` )
271-
272270 // Store original response methods
273271 const originalJson = res . json . bind ( res )
274272 const originalSend = res . send . bind ( res )
@@ -281,23 +279,18 @@ const invalidateCache = (req, res, next) => {
281279 const performInvalidation = ( data ) => {
282280 // Prevent duplicate invalidation
283281 if ( invalidationPerformed ) {
284- console . log ( '[CACHE INVALIDATE] Skipping duplicate invalidation' )
285282 return
286283 }
287284 invalidationPerformed = true
288285
289- console . log ( `[CACHE INVALIDATE] Response handler called with status ${ res . statusCode } ` )
290-
291286 // Only invalidate on successful write operations
292287 if ( res . statusCode >= 200 && res . statusCode < 300 ) {
293288 // Use originalUrl to get the full path (req.path only shows the path within the mounted router)
294289 const path = req . originalUrl || req . path
295- console . log ( `[CACHE INVALIDATE] Processing path: ${ path } (originalUrl: ${ req . originalUrl } , path: ${ req . path } )` )
296290
297291 // Determine what to invalidate based on the operation
298292 if ( path . includes ( '/create' ) || path . includes ( '/bulkCreate' ) ) {
299293 // For creates, use smart invalidation based on the created object's properties
300- console . log ( '[CACHE INVALIDATE] Create operation detected - using smart cache invalidation' )
301294
302295 // Extract the created object(s)
303296 const createdObjects = path . includes ( '/bulkCreate' )
@@ -314,17 +307,11 @@ const invalidateCache = (req, res, next) => {
314307 // This ensures queries matching this object will be refreshed
315308 cache . invalidateByObject ( obj , invalidatedKeys )
316309 }
317-
318- console . log ( `[CACHE INVALIDATE] Invalidated ${ invalidatedKeys . size } cache entries using smart invalidation` )
319- if ( invalidatedKeys . size > 0 ) {
320- console . log ( `[CACHE INVALIDATE] Invalidated keys: ${ Array . from ( invalidatedKeys ) . slice ( 0 , 5 ) . join ( ', ' ) } ${ invalidatedKeys . size > 5 ? '...' : '' } ` )
321- }
322310 }
323311 else if ( path . includes ( '/update' ) || path . includes ( '/patch' ) ||
324312 path . includes ( '/set' ) || path . includes ( '/unset' ) ||
325313 path . includes ( '/overwrite' ) || path . includes ( '/bulkUpdate' ) ) {
326314 // For updates, use smart invalidation based on the updated object
327- console . log ( '[CACHE INVALIDATE] Update operation detected - using smart cache invalidation' )
328315
329316 // Extract updated object (response may contain new_obj_state or the object directly)
330317 const updatedObject = data ?. new_obj_state ?? data
@@ -360,20 +347,13 @@ const invalidateCache = (req, res, next) => {
360347 const versionIds = [ objIdShort , previousId , primeId ] . filter ( id => id && id !== 'root' ) . join ( '|' )
361348 const historyPattern = new RegExp ( `^(history|since):(${ versionIds } )` )
362349 const historyCount = cache . invalidate ( historyPattern )
363-
364- console . log ( `[CACHE INVALIDATE] Invalidated ${ invalidatedKeys . size } cache entries (${ historyCount } history/since for chain: ${ versionIds } )` )
365- if ( invalidatedKeys . size > 0 ) {
366- console . log ( `[CACHE INVALIDATE] Invalidated keys: ${ Array . from ( invalidatedKeys ) . slice ( 0 , 5 ) . join ( ', ' ) } ${ invalidatedKeys . size > 5 ? '...' : '' } ` )
367- }
368350 } else {
369351 // Fallback to broad invalidation if we can't extract the object
370- console . log ( '[CACHE INVALIDATE] Update operation (fallback - no object data)' )
371352 cache . invalidate ( / ^ ( q u e r y | s e a r c h | s e a r c h P h r a s e | i d | h i s t o r y | s i n c e ) : / )
372353 }
373354 }
374355 else if ( path . includes ( '/delete' ) ) {
375356 // For deletes, use smart invalidation based on the deleted object
376- console . log ( '[CACHE INVALIDATE] Delete operation detected - using smart cache invalidation' )
377357
378358 // Get the deleted object from res.locals (set by delete controller before deletion)
379359 const deletedObject = res . locals . deletedObject
@@ -408,20 +388,13 @@ const invalidateCache = (req, res, next) => {
408388 const versionIds = [ objIdShort , previousId , primeId ] . filter ( id => id && id !== 'root' ) . join ( '|' )
409389 const historyPattern = new RegExp ( `^(history|since):(${ versionIds } )` )
410390 const historyCount = cache . invalidate ( historyPattern )
411-
412- console . log ( `[CACHE INVALIDATE] Invalidated ${ invalidatedKeys . size } cache entries (${ historyCount } history/since for chain: ${ versionIds } )` )
413- if ( invalidatedKeys . size > 0 ) {
414- console . log ( `[CACHE INVALIDATE] Invalidated keys: ${ Array . from ( invalidatedKeys ) . slice ( 0 , 5 ) . join ( ', ' ) } ${ invalidatedKeys . size > 5 ? '...' : '' } ` )
415- }
416391 } else {
417392 // Fallback to broad invalidation if we can't extract the object
418- console . log ( '[CACHE INVALIDATE] Delete operation (fallback - no object data from res.locals)' )
419393 cache . invalidate ( / ^ ( q u e r y | s e a r c h | s e a r c h P h r a s e | i d | h i s t o r y | s i n c e ) : / )
420394 }
421395 }
422396 else if ( path . includes ( '/release' ) ) {
423397 // Release creates a new version, invalidate all including history/since
424- console . log ( '[CACHE INVALIDATE] Cache INVALIDATE: release operation' )
425398 cache . invalidate ( / ^ ( q u e r y | s e a r c h | s e a r c h P h r a s e | i d | h i s t o r y | s i n c e ) : / )
426399 }
427400 }
0 commit comments