什么是Memcached的相比,.NET缓存系统的优势是什么?缓存、优势、系统、Memcached

2023-09-04 00:38:46 作者:闹心。

我看到有些人在一个开发团队使用 Memcached的缓存数据库结果,而不是内置的.NET Framework缓存系统。我不明白清楚为什么他们会使用这个特定的缓存。

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.

也许性能更好。

反正是有使用Memcached的(而不是本机.NET缓存)?任何真正的优势

Anyway, is there any real advantages of using Memcached (and not native .NET Cache)?

推荐答案

Memcached是分布式的 - 关键的是,这意味着如果我有服务器访问缓存的集群,所有的人都基本上是读取和写入相同的缓存。内置的净缓存不具备该功能(至少我所知道的ASP.Net一个没有)。

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):

如果A机计算/读取值,并将其放置在缓存中,B机没有得到任何与此利益。每台机器需要独立维护,并填写自己的缓存。这也可能会浪费空间,同一条目可能是present在许多不同的机器上的高速缓存。 如果机器B无效缓存条目,A机不会意识到该法律的失效,并可能继续使用陈旧/过时的数据

的Memcached既没有这些问题 - 一旦条目被放置在高速缓冲存储器集群中的所有机器可以检索相同的缓存项目。无效的缓存中的条目为每个人无效的。

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.

缺点

如果您的应用程序需要的机器集群上函数,那么它很可能,你将受益于分布式缓存,但是如果你的应用程序只需要在一台机器上运行,那么你将无法获得使用任何好处分布式缓存,可能会更好使用内置的.Net缓存。

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.

在访问一个memcached的缓存需要间/网络通信,这将有超过净缓存这是进程一个小的性能损失。 在Memcached工作作为外部进程/服务,这意味着你需要安装/在生产环境中运行该服务。同样,净缓存不需要这一步,因为他们是在主持过程。