Yet another question about which NoSQL to choose. However, I haven\'t found yet someone asking for this type of purpose, message storing...
I have an Erlang Chat Ser
I'd recommend using distributed key/value store like Riak or Couchbase and keep the whole message log for each user serialized (into binary erlang terms or JSON/BSON) as one value.
So with your usecases it will look like:
The obvious limitation - message log has to fit in memory.
If you decide to store each message individually it will require from distributed database to sort them after retrieval if you want them to be in time-order, so it will hardly help to handle larger-than-memory datasets. If it is required - you will anyway end up with some more tricky scheme.