views:

77

answers:

2

I'm using memcache for caching (obviously) which is great. But I'm also using it as a cross-request/process data store. For instance I have a web chat on one of my pages and I use memcache to store the list of online users in it. Works great but it bothers me that if I have to flush the whole memcache server (for whatever reason) I loose the online list. I also use it to keep record of views for some content (I then periodically update the actual rows in the DB), and if I clear the cache I loose all data about views (from the last write to db).

So what I'm asking is this: what should I use instead of memcache for this kind of things? It needs to be fast and preferably store it's data in memory. I think some noSQL product would be a good fit here, but I've no idea which one. I'd like to use something that I could use for other use cases in the future, analytics come to mind (what are users searching the most for instance).

I'm using PHP so it has to have good bindings for it.

+6  A: 

Redis! It's like memcache on steroids (the good kind). Here are some drivers.

Redis is an advanced key-value store. It is similar to memcached but the dataset is not volatile, and values can be strings, exactly like in memcached, but also lists, sets, and ordered sets. All this data types can be manipulated with atomic operations to push/pop elements, add/remove elements, perform server side union, intersection, difference between sets, and so forth. Redis supports different kind of sorting abilities.

Kendall Hopkins
Beat me by a few seconds. +1 for redis. Helps that it works much like memcache, but can persist. Probably should also mention that it has four different drivers for PHP. I'm sure one of them will work in a way that you'd like.
lazyconfabulator
Just out of curiosity: could one use redis instead of memcache? If yes, why?
Jan Hančič
Redis is a full blown persistence data structure storage daemon. Much like a RDMS (without ACID). It allows for many complex data types such as list, sets, and ordered sets. To me, it sounds like it would be a good fit for your needs.
Kendall Hopkins
@Kendall I assume you did exceed with Scalable, Delayed PHP processing
Alfred
+1  A: 

You could try memcachedb. It uses exactly the same protocol as memcache, but it's persistent store.

You could also try cassandra or redis

Aaron Jackson
I'd only consider cassandra ONLY if you want to fight some *serious* scaling uses. Currently it's only being used by very large sites: digg, facebook and friends.
Kendall Hopkins
I actually agree completely with what this guy just said
Aaron Jackson