C# Memcached 与 Windows 和 .NET

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/351635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 00:11:16  来源:igfitidea点击:

Memcached with Windows and .NET

c#.net-3.5memcacheddistributed-caching

提问by Funky81

Is there anyone already implement memcached for production use in Windows environment? Because many blogs that I've read, it's not recommended to run memcached in Windows especially for production use, for example running memcached on windows.

是否有人已经在 Windows 环境中实现了用于生产用途的 memcached?因为我读过很多博客,所以不建议在 Windows 中运行 memcached,特别是用于生产用途,例如在 windows 上运行 memcached

And one more thing, which memcached client that is good to use with c# and .net 3.5 ? I've found many alternate such as Memcached Providers @ Codeplex, Beitmemcached, and memcached provider @ Sourceforge

还有一件事,哪个 memcached 客户端适合与 c# 和 .net 3.5 一起使用?我发现了许多替代方案,例如Memcached Providers @ CodeplexBeitmemcachedmemcached provider @ Sourceforge

采纳答案by Cherian

Why do you need to run memcached on windows? It's an expensive affair in a production environment.

为什么需要在 windows 上运行 memcached?在生产环境中这是一件昂贵的事情。

If your code needs to run in a Windows environment get a windows memcached client and talk to a *nix based memcached machine.

如果您的代码需要在 Windows 环境中运行,请获取 Windows memcached 客户端并与基于 *nix 的 memcached 机器对话。

In a production environment running memcached on Server 2003 or 2008 would mean that you get licenses for all those boxes. Linux will offer you all the OSS benefits. TCO will rise linearly with memcached on Windows

在 Server 2003 或 2008 上运行 memcached 的生产环境中,您将获得所有这些机器的许可证。Linux 将为您提供所有 OSS 优势。Windows 上的 memcached 将导致 TCO 线性上升

Edit:

编辑:

It's been around 1.5 years since I wrote this answer and lot of things have changed since. You've to take notice, especially when someone like Dustin comments.
So here's how you can get memcached on windows running. Download memcached for windows from Couchbase (formerly Northscale).
Typically if you plan to run memcached on the same production machine you'd want to start it in limited memory, i.e. define the maximum memory memcached is allowed to use.

我写这个答案已经过去了大约 1.5 年,从那时起很多事情都发生了变化。你必须注意,尤其是当像达斯汀这样的人发表评论时。
因此,这里是如何在运行的 Windows 上获取 memcached 的方法。从 Couchbase(以前称为 Northscale)下载适用于 windows 的 memcached
通常,如果您计划在同一台生产机器上运行 memcached,您希望在有限的内存中启动它,即定义 memcached 允许使用的最大内存。

c:\Program Files\memcached>memcached.exe -m 128.

c:\Program Files\memcached>memcached.exe -m 128。

Here memcached runs with a maximum of 128 mb usage. You don't want memcached to take up all the memory on your webserver.

此处 memcached 以最大 128 mb 的使用量运行。您不希望 memcached 占用您网络服务器上的所有内存。

The moment you decided to scale outmemcached you'll need to consider what I said earlier. Additionally compress your values in the key value combinations. Web servers typically consume very little CPU (2-3%) usage and compression brings in a lot of value to network throughout in comparison to the CPU usage. If you are too concerned about normal compression, try LZO

当您决定扩展memcached 时,您需要考虑我之前所说的内容。此外,在键值组合中压缩您的值。Web 服务器通常消耗很少的 CPU (2-3%) 使用率,与 CPU 使用率相比,压缩为整个网络带来了很多价值。如果你太在意正常压缩,试试LZO

回答by lomaxx

i don't know what the project you're working on is, but you might like to take a look at the Microsoft Velocity projectFrom the page:

我不知道你正在做的项目是什么,但你可能想 从页面上查看Microsoft Velocity 项目

"Velocity" is a distributed in-memory application cache platform for developing scalable, high-performance applications. "Velocity" can be used to cache any common language runtime (CLR) object and provides access through simple APIs. The key aspects of "Velocity" are distributed cache performance, scalabily, and availability.

“Velocity”是一个分布式内存应用程序缓存平台,用于开发可扩展的高性能应用程序。“Velocity”可用于缓存任何公共语言运行时 (CLR) 对象,并通过简单的 API 提供访问。“速度”的关键方面是分布式缓存性能、可扩展性和可用性。

I've seen a couple of demo's and it looks like it has really nice integration with .net framework.

我看过几个演示,看起来它与 .net 框架的集成非常好。

The problem with the client API's is that you still have to have an instance of memcached running on another box somewhere preferrably as you've noted, using the LAMP stack. Using velocity means you're still going to be running on the same stack and there's tighter integration across the .net platform.

客户端 API 的问题在于,您仍然必须使用 LAMP 堆栈在另一个盒子上运行一个 memcached 实例,最好是如您所指出的那样。使用速度意味着您仍将在同一个堆栈上运行,并且跨 .net 平台有更紧密的集成。

Having said that, if you want to use velocity as a cache for other .net applications you might find yourself having to write your own API to expose the velocity data for consumption.

话虽如此,如果您想将速度用作其他 .net 应用程序的缓存,您可能会发现自己必须编写自己的 API 来公开速度数据以供使用。

回答by Silvas

Velocity is a bit more involved to administer, but it is far, far more powerful then memcached. I am not anti-memcached, not in the least bit, it is great. But moving forward, new projects that are pure .NET based are crazy not to leverage Velocity, even in its current unreleased state.

Velocity 的管理涉及更多,但它比 memcached 强大得多。我不反对 memcached,一点也不,它很棒。但是展望未来,纯粹基于 .NET 的新项目不利用 Velocity 是疯狂的,即使在当前未发布的状态下也是如此。

回答by Silvas

The problem with the client API's is that you still have to have an instance of memcached running on another box somewhere preferrably as you've noted, using the LAMP stack.

客户端 API 的问题在于,您仍然必须使用 LAMP 堆栈在另一个盒子上运行一个 memcached 实例,最好是如您所指出的那样。

Not at all true. The LAMP (Linux, Apache, MySQL, PHP) stack is not required to run Memcached. I currently prefer memcached over velocity until velocity is out of CTP. I've played around with velocity for a bit but found it too unwieldy. I follow that whole KISS thing, you know... keep it simple. Nothing simpler than caching... Get(key)... Put(key, value)... Destroy(Key).

完全不是真的。运行 Memcached 不需要 LAMP(Linux、Apache、MySQL、PHP)堆栈。我目前更喜欢 memcached 而不是速度,直到速度超出 CTP。我已经玩了一会儿速度,但发现它太笨拙了。我关注整个 KISS 的事情,你知道...保持简单。没有什么比缓存更简单的了... Get(key)... Put(key, value)... Destroy(Key)。

回答by Nicholas Piasecki

Since Velocity didn't exist at the time, I used a memcached port to Windows for the company that I work for, Skiviez. It mainly only exists to provide a centralized cache for multiple worker processes on the same machine. It's been running fine about 18 months now on an e-commerce site that sees modest use (~18,500 hits/day). The client that I used was Enyimintegrated as a cache provider for iBATIS.NET. That client seems to work well enough; memcached clients are not very complicated to begin with, either.

由于当时不存在 Velocity,因此我使用了 Windows 的 memcached 端口,用于我工作的公司 Skiviez。它的存在主要是为同一台机器上的多个工作进程提供一个集中的缓存。它在一个使用率适中的电子商务网站上运行了大约 18 个月(约 18,500 次/天)。我使用的客户端是Enyim集成为 iBATIS.NET 的缓存提供程序。那个客户似乎工作得很好;memcached 客户端也不是很复杂。

If I had to do it again, I'd probably look at Velocity if I was committed to remaining on Windows for my distributed caching solution. But it's working now, so I'm not going to touch it.

如果我不得不再做一次,如果我承诺继续使用 Windows 来获取分布式缓存解决方案,我可能会考虑 Velocity。但它现在正在工作,所以我不会去碰它。

(Aside: Since then, I negated most of the need for the cache by adding certain Cache*columns to key tables in the database that are updated by a scheduled task every evening. This ended up putting much less strain on resources all around, from the initial hit in CPU time by querying the database to the subsequential strain on memory availability by keeping the cached results sitting in memcached. It also made it much more explicit in the code when a cached version of the data is being accessed versus a calculated-on-the-fly version. I'm sure you have lots of reasons to use a distributed cache, but it's always worth a shot to take a step back and question whether or not you really need it!)

(旁白:从那时起,我通过向Cache*数据库中的关键表添加某些列来否定对缓存的大部分需求,这些列每天晚上由计划任务更新。这最终对周围资源的压力大大减轻了,从最初通过将缓存的结果保存在 memcached 中,通过查询数据库对内存可用性的后续压力来降低 CPU 时间。当访问缓存版本的数据时,它也使代码中的数据更加明确,而不是基于计算The-fly 版本。我相信你有很多理由使用分布式缓存,但退一步质疑你是否真的需要它总是值得一试的!)

回答by kay.one

have a look at SharedCache. its open source, easy to use and very reliable.

看看SharedCache。它是开源的,易于使用且非常可靠。

high-performance, distributed memory object caching system, generic in nature, but intended to speeding up dynamic web and / or win applications by alleviating database load. Don't forget to visit us at http://www.sharedcache.com

高性能、分布式内存对象缓存系统,本质上是通用的,但旨在通过减轻数据库负载来加速动态 Web 和/或赢得应用程序。不要忘记访问我们的网站 http://www.sharedcache.com

回答by mythz

I'm suprised no one here has yet to mention Redis- it is one of the most feature-rich and fastest (110,000 SET's per second on an entry level linux box) key-value data stores with rich data-structure support for strings, sets, lists, sorted sets and hashes.

我很惊讶这里没有人提到Redis- 它是功能最丰富、速度最快(入门级 linux 机器上每秒 110,000 个 SET)的键值数据存储之一,具有对字符串的丰富数据结构支持,集合、列表、排序集合和散列。

Although windows is not an officially supported platform, it runs perfectly under windows with all tests passing. I have windows builds (using Cygwin) available here: https://github.com/ServiceStack/ServiceStack.Redis#redis-server-builds-for-windows

尽管 windows 不是官方支持的平台,但它在 windows 下完美运行,所有测试均通过。我在这里有 Windows 版本(使用 Cygwin):https: //github.com/ServiceStack/ServiceStack.Redis#redis-server-builds-for-windows

It also has client bindings for nearly every programming language in use today. I maintain a rich Open Source C# Redis client with native API support for any C# POCO type, transaction support and Thread-safe client managers that are ready to be dropped into any IOC at: https://github.com/ServiceStack/ServiceStack.Redis

它还为当今使用的几乎所有编程语言提供了客户端绑定。我维护了一个丰富的开源 C# Redis 客户端,具有对任何 C# POCO 类型、事务支持和线程安全客户端管理器的本机 API 支持,这些客户端管理器已准备好放入任何 IOC:https: //github.com/ServiceStack/ServiceStack。 Redis

回答by bopapa_1979

I know I'm a little late to the party here, and there are already tons of good answers.

我知道我参加聚会有点晚了,已经有很多好的答案了。

We've used Membase on Windows Server with great success. It is 100% compatible with Memcached, and has a nice GUI installer and web configuration server build it. It is extremely easy to administer.

我们在 Windows Server 上使用 Membase 取得了巨大成功。它与 Memcached 100% 兼容,并有一个很好的 GUI 安装程序和 Web 配置服务器来构建它。管理起来非常容易。

There are also other NoSQL features included, which are outside the scope of this thread, but worth looking at. They do have a free license for development, testing, and (limited) production servers.

还包括其他 NoSQL 功能,这些功能超出了本线程的范围,但值得一看。他们确实拥有用于开发、测试和(有限)生产服务器的免费许可证。

Membase Downloads

会员下载

That same page has a Windows Install for Memcached only, if you don't want any of the extra features in Membase.

如果您不想要 Membase 中的任何额外功能,则同一页面仅具有适用于 Memcached 的 Windows 安装。

回答by Brent Matzelle

If you're interested in running a memcached client on Windows then there are two additional open source servers that can do the job. Both implement the standard memcached server protocol and are written in Java so they run on Windows.

如果您对在 Windows 上运行 memcached 客户端感兴趣,那么还有两个额外的开源服务器可以完成这项工作。两者都实现了标准的 memcached 服务器协议并用 Java 编写,因此它们可以在 Windows 上运行。