Search code examples
ruby-on-railsrubymongodbredismongomapper

Using both Redis and MongoDB in Rails App


I am building a high volume Twitter streaming application. I want to store the raw tweets in a Redis store since the spikes can be very large (10s of thousands per second), then run a separate process to grab tweets from Redis and parse and store in various MongoDB collections.

I'm familiar with MongoMapper, is there something similar for a Rails app with Redis and can you use both? I'd essentially have a simple model object for the raw tweets which should connect to Redis and other models for the various MangoDB collections via MongoMapper.


Solution

  • You can serialize tweets to a (JSON) string and just store them like this in Redis. Then later read, parse and save to MongoDB.

    Infinite flexibility and no need for redis mapper libraries (which don't exist, AFAIK).

    In my app there's a similar functionality. I use the wonderful Resque to store "tweets" in redis to be processed later.