Java Memcached 客户端

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/731738/
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-11 18:49:14  来源:igfitidea点击:

Java Memcached Client

javaweb-applicationsmemcached

提问by Java Guy

Which is the best Java memcached client, and why?

哪个是最好的 Java memcached 客户端,为什么?

采纳答案by Dustin

As the author of spymemcached, I'm a bit biased, but I'd say it's mine for the following reasons:

作为spymemcached的作者,我有点偏见,但我会说它是我的,原因如下:

Designed from scratch to be non-blocking everywhere possible.

从头开始设计为在任何可能的地方都是非阻塞的。

When you ask for data, issue a set, etc... there's one tiny concurrent queue insertion and you get a Future to block on results (with some convenience methods for common cases like get).

当您请求数据、发布集合等时……有一个微小的并发队列插入,并且您会得到一个 Future 来阻止结果(使用一些方便的方法来处理诸如 get 之类的常见情况)。

Optimized Aggressively

积极优化

You can read more on my optimizationspage, but I do whole-application optimization.

您可以在我的优化页面上阅读更多内容,但我会进行整个应用程序的优化。

I still do pretty well in micro-benchmarks, but to compare fairly against the other client, you have to contrive unrealistic usage patterns (for example, waiting for the response on every set operation or building locks around gets to keep them from doing packet optimization).

我在微基准测试中仍然做得很好,但要与其他客户端进行公平比较,您必须设计不切实际的使用模式(例如,等待每个设置操作的响应或围绕获取构建锁以防止它们进行数据包优化)。

Tested Obsessively

痴迷地测试

I maintain a pretty rigorous test suite with coverage reportson every release.

我维护了一个非常严格的测试套件,其中包含每个版本的覆盖率报告

Bugs still slip in, but they're usually pretty minor, and the client just keeps getting better. :)

错误仍然存​​在,但它们通常很小,并且客户端会变得越来越好。:)

Well Documented

有据可查

The examplespage provides a quick introduction, but the javadocgoes into tremendous detail.

示例页面提供了一个简要介绍,但javadoc的进入极大的细节。

Provides High-level Abstractions

提供高级抽象

I've got a Map interface to the cache as well as a functional CAS abstraction. Both binary and text support an incr-with-default mechanism (provided by the binary protocol, but rather tricky in text).

我有一个缓存的 Map 接口以及一个功能性的 CAS 抽象。二进制和文本都支持 incr-with-default 机制(由二进制协议提供,但在文本中相当棘手)。

Keeps up with the Specs

跟上规格

I do a lot of workon the server itself, so I keep up with protocol changes.

我在服务器本身上做了很多工作,所以我跟上协议的变化。

I did the first binary protocol server implementations (both a test server and in memcached itself), and this was the first production-ready client to support it, and does so first-class.

我完成了第一个二进制协议服务器实现(测试服务器和 memcached 本身),这是第一个支持它的生产就绪客户端,并且是一流的。

I've also got support for several hash algorithms and node distribution algorithms, all of which are well-tested for every build. You can do a stock ketama consistent hash, or a derivative using FNV-1 (or even java's native string hashing) if you want better performance.

我还支持多种哈希算法和节点分布算法,所有这些算法都经过了针对每个构建的良好测试。如果您想要更好的性能,您可以使用 FNV-1(甚至 Java 的本机字符串散列)进行股票 ketama 一致性哈希或衍生。

回答by cletus

There is the memcached client for Javaand spymemcached. Not much experience with either though.

用于 Javaspymemcachedmemcached 客户端。两者都没有太多经验。

回答by Steve B.

As of about a year ago, when I had to use a memcached java client, the spymemcached connector was described as an optimized API with more features. Since then there've been a number of new releases of the memcached client so it may be worth checking out.

大约一年前,当我不得不使用 memcached java 客户端时,spymemcached 连接器被描述为具有更多功能的优化 API。从那时起,memcached 客户端已经发布了许多新版本,因此可能值得一试。

FWIW the spy client has worked perfectly for me.

FWIW 间谍客户端非常适合我。

回答by Langali

I have been using SpyMemcached and have to agree that it is the best one available out there, with lots of newer improvements.

我一直在使用 SpyMemcached 并且不得不同意它是目前可用的最好的一个,并且有很多更新的改进。

回答by Langali

Please try xmemcached, it is also nio based and have some powerful features.

请尝试xmemcached,它也是基于 nio 并具有一些强大的功能。

回答by newroot

I believe memcached java clientis the best client.

我相信memcached java 客户端是最好的客户端。

Features

特征

  • Binary protocol support. fastest way to access the key/value stored in memcached server.
  • UDP protocol support. You can set key with tcp protocol, and get with udp protocol. Acctually, some big corporations are doing like this.
  • Support customized serialization and deserialization.
  • Connection pool with NIO and direct buffer. Dynamically increase connections when out of use for the connection pool.
  • 二进制协议支持。访问存储在 memcached 服务器中的键/值的最快方法。
  • UDP 协议支持。可以用tcp协议设置key,用udp协议获取。事实上,一些大公司正在这样做。
  • 支持自定义序列化和反序列化。
  • 带有 NIO 和直接缓冲区的连接池。连接池不使用时动态增加连接。

Performance

表现

  • Refer to performancefor a benchmark test of existing popular memcached java clients.
  • Deserializing while receiving the response
  • Performance tuning into each line of the source code.
  • 有关现有流行的 memcached java 客户端的基准测试,请参阅性能
  • 接收响应时反序列化
  • 对源代码的每一行进行性能调整。

回答by Ashwin Jayaprakash