Caching Mongoose Models

1,145 views
Skip to first unread message

bill

unread,
Apr 16, 2012, 6:54:19 PM4/16/12
to Mongoose Node.JS ORM
What's the suggested way to cache Mongoose Models in something like
Redis? Is the best way to just stringify the model to store in Redis
and then repopulate the model on retrieve i.e. return new
Post(JSON.parse(json));?

Is there a better/more efficient way?

Thanks!
bill

bill

unread,
Apr 18, 2012, 3:22:02 PM4/18/12
to Mongoose Node.JS ORM
Sorry for the confusing terminology, I meant caching the object that
is stored in MongoDB when using Mongoose, not the model definition
itself. Basically I want to cache the result of a mongoose query
(Post.findOne(...)) so that I don't have to keep retrieving the same
object from the MongoDB.

On Apr 16, 4:04 pm, Kevin Sakhuja <kevin.sakh...@gmail.com> wrote:
> I'm pretty new so ignore if I'm being stupid.
>
> Why would u want to cache the model? Just load it var model = require (model) - it'll just get loaded in memory, faster than going to redis server.
>
> Best,
> Kev
> > --
> >http://mongoosejs.com
> >http://github.com/learnboost/mongoose
> > You received this message because you are subscribed to the Google
> > Groups "Mongoose Node.JS ORM" group.
> > To post to this group, send email to mongoo...@googlegroups.com
> > To unsubscribe from this group, send email to
> > mongoose-orm...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/mongoose-orm?hl=en

Aaron Heckmann

unread,
Apr 18, 2012, 5:53:03 PM4/18/12
to mongoo...@googlegroups.com
If its a single core app and you don't need shared state across app servers you could just shove it in a hash locally as well.

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages