DEV Community

Discussion on: Caching in Node.js using Redis

Collapse
 
franciscomendes10866 profile image
Francisco Mendes

There are several ways around this. But I think the simplest would be to write the key like this: post-${id} and then there would be a middleware to fetch the cached post or the comment, this according to the controller.

I hope I understood your question πŸ™

Collapse
 
samwizzy profile image
Sammie Knob

Okay thanks, you did get my question right.

This actually means that there will be a different middleware to handle this, right?

Thread Thread
 
franciscomendes10866 profile image
Francisco Mendes

Thank god πŸ™ Yes, that would imply having a middleware for the posts and another one for the comments. I think it would be a quick and simple solution. 😊

Thread Thread
 
samwizzy profile image
Sammie Knob

Great! Thank Francisco, i really appreciate.
Once again, awesome pieceπŸ€πŸΌπŸ™‚

Thread Thread
 
franciscomendes10866 profile image
Francisco Mendes

Thank you very much πŸ™