I saw some people in a development team using Memcached to cache database results, instead of built-in .NET Framework Cache system. I do not understand clearly why would they use this specific cache.
Maybe the performance is better.
Anyway, is there any real advantages of using Memcached (and not native .NET Cache)?
Redis uses a single core and shows better performance than Memcached in storing small datasets when measured in terms of cores. Memcached implements a multi-threaded architecture by utilizing multiple cores. Therefore, for storing larger datasets, Memcached can perform better than Redis.
Although they are both easy to use and offer high performance, there are important differences to consider when choosing an engine. Memcached is designed for simplicity while Redis offers a rich set of features that make it effective for a wide range of use cases.
Memcached can serve cached items in less than a millisecond, and enables you to easily and cost effectively scale for higher loads. Memcached is popular for database query results caching, session caching, web page caching, API caching, and caching of objects such as images, files, and metadata.
They both have very basic difference while storing value. Memcache mostly considers every value as string whereas Memcached stores it value's original type. Thumbs up for your answer !
Memcached is distributed - crucially this means that if I have a cluster of servers accessing the cache, all of them are essentially reading from and writing to the same cache. The built in .Net cache does not have this feature (at least I know the ASP.Net one doesn't).
As each machine has its own independent cache this means that (for example):
Memcached has neither of those problems - once an entry is placed in the cache all machines in the cluster can retrieve the same cached item. Invalidating an entry in the cache invalidates it for everyone.
Disadvantages
If your application needs to function on a cluster of machines then it is very likely that you will benefit from a distributed cache, however if your application only needs to run on a single machine then you won't gain any benefit from using a distributed cache and will probably be better off using the built-in .Net cache.
A better comparison for Memcached would actually be Azure App Fabric Caching, which was added with .NET 4 and Azure. It is a distributed cluster-able cache solution intended for clustered and cloud computing. However, Memcached has also been around for a long time (2003-ish I think), so is well established, and considered to be the benchmark by which others are judged. Memcached has also been ported to just about every language out there, and can be run on linux or windows servers. Azure Caching is still relatively new, so not many people have really used it yet.
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