views:

459

answers:

4

Is it possible to use two session types simultaneously in Rails? Memcached for speed on reads and say SQL for persistence?

I hate the idea of losing all sessions on reboots.

MemcacheDB as mentioned below looks promising, but the idea would be to make all writes to disk, and all reads come from memory if possible.

+1  A: 

For persistence you could use MemcacheDB rather then SQL.

vartec
+1  A: 

Take a look at MongoDB. It uses memory mapped files, so is incredibly fast and should perform at a comparative level to MemCached, but will also persistently store your data.

MongoDB is a schema-less database that should support everything you're looking for and proved the flexibility to do whatever you like with this data.

Alan
A: 

Redis FTW (http://code.google.com/p/redis/)

deepthawtz
A: 

Check out cache-money. It's a read-through, write-through cache that can be attached to most rails models and store results in memcache...

Read-Through: Queries like User.find(:all, :conditions => ...) will first look in Memcached and then look in the database for the results of that query. If there is a cache miss, it will populate the cache.

Write-Through: As objects are created, updated, and deleted, all of the caches are automatically kept up-to-date and coherent.

I use it on a couple of projects, and it works as described and seems to be exactly what you want. Major win for many environments.

corprew