When having full control over the application stack. Batching multiple requests into one message, indicates that there is no order dependency on the encapsulated messages. Caching database queries in this scenario is a good optimisation. E.g. DataLoader
I propose adding a .shared mechanism. In the way .stream is exposed
Example
// create as normal
const ChatSchema = new mongoose.schema({ text: String });
const Chat = moduleStream('Chat', ChatSchema);
// create a shared ref
const ChatWithCachedQueries = Chat.shared()
// use shared ref
workTodo({Chat:ChatWithCachedQueries})
function async workTodo(modules){
// this find call will be Cached, so if the same query is call on this shared module.
// It will return the same value instead of hitting the database again
const chats = await modules.Chat.find({})
// ... do something with chats
}
// reuse shared ref
workSomeOtherWork({Chat:ChatWithCachedQueries})
Question: What if the DB object is change in App?.. = this change will be reflected to all instances
When having full control over the application stack. Batching multiple requests into one message, indicates that there is no order dependency on the encapsulated messages. Caching database queries in this scenario is a good optimisation. E.g. DataLoader
I propose adding a
.sharedmechanism. In the way.streamis exposedExample
Question: What if the DB object is change in App?.. = this change will be reflected to all instances