-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Is it possible to create multiple mongoose.Mongoose instances and each of them to have their own cache.
My Setup
type-graphql backend with typegoose/mongoose
Code here
My Question
I am trying to have each GraphQL request create a separate mongoose instance with its own cache like this
export const getMongooseInstance = async (): Promise<Mongoose> => {
const mongooseInstance = await connect(MONGO_DB_URL);
cachegoose(mongooseInstance);
return mongooseInstance;
};
See here
The idea is that I can pass my instance into getModelForClass like this
getModelForClass(clazz, { existingMongoose: this.mongooseInstance })
See here.
So that the models for each request will use a separate mongooseInstance with a separate cache. I want this so that when a request requests the same data twice the cache is used.
However with my current implementation the cache seems to be global across the created mongoose instances.
Is this behaviour possible and if not how could I extend cachegoose to add this functionality.
Thanks.
Metadata
Metadata
Assignees
Labels
No labels