开发者

Google MapMaker maximumSize Beta?

MapMaker maximumSize in google guava library is marked as @Beta. It's a very useful feature to set the maximum size when you use it 开发者_如何学Goas a cache and I would like to use it in production code. From experience with other google products beta can be pretty solid. Anyone know why it's a @Beta?


It is used in production at Google and there are no immediate plans on API changes. There is consensus to support weighted entries and we'll likely continue to evolve the algorithm to be closer to ConcurrentLinkedHashMap's. In this case @Beta is just to indicate that the method contract isn't officially set in stone.


From the javadoc:

Signifies that a public API (public class, method or field) is subject to incompatible changes, or even removal, in a future release. An API bearing this annotation is exempt from any compatibility guarantees made by its containing library.

So it doesn't mean it's questionable quality, or unsuitable for production use, they just reserve the right to change it later.


If your project is an end application that is not intended to be embedded in other peoples' applications, then anything with @Beta is totally safe to use. The API may change later and IMO the greatest risk you run is that you might have to change your code a little bit because a method signature changed.

If, on the other hand, you are developing some sort of framework where you expect your project will be on the classpath of many clients, you probably want to avoid @Beta. You never know if your clients will have a different version of Guava on the classpath -- in which case unpredictable things can happen.

ColinD explains this best here: Best Way To Use Guava

edit: Ah yes, and to answer your specific question of why call it @Beta -- it's just to document this fact that MapMaker maximumsize is still subject to change in the next release (It's not that the code is thought to be flaky, unstable, or unsuitable for production)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜