How do you make the id unique for each key in the redis key pair structure, i.e lets say you have a collection called "Post", and another "Comment" and they both have a document with same id, is there a way to map this id to their Model like so:
post-5
comment-5
...to avoid conflict with the ids within the redis in-memory database
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.
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. 😊
How do you make the id unique for each key in the redis key pair structure, i.e lets say you have a collection called "Post", and another "Comment" and they both have a document with same id, is there a way to map this id to their Model like so:
post-5
comment-5
...to avoid conflict with the ids within the redis in-memory database
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 🙏
Okay thanks, you did get my question right.
This actually means that there will be a different middleware to handle this, right?
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. 😊
Great! Thank Francisco, i really appreciate.
Once again, awesome piece🤝🏼🙂
Thank you very much 🙏