Can we use MongoDB as a replacement of Memory Caching library (memcache and memcached).?
and what are the deference in MongoDB and Memory Caching Library.
MongoDB is schemaless, which means that the database does not have a fixed data structure. This means that as the data stored in the database gets larger and larger, MongoDB is able to operate much faster than Redis. Redis is only significantly faster when the stored data is relatively small in size.
When storing data, Redis stores data as specific data types, whereas Memcached only stores data as strings. Because of this, Redis can change data in place without having to re-upload the entire data value. This reduces network overhead.
Just a note: as it was confirmed by the current maintainer on Twitter, Memcached is still actively developed / maintained.
One of the main problems with MongoDB as a cache store is that it does not have expiration mechanism. More details about that you can find in this answer.
UPDATED Since MongoDB v2.2 it allows TTL for collections. Thanks to JohnnyHK for pointing.
I suggest to use Redis for caching and MongoDB as a database. They work nice together.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With