Memcache与Java内存 [英] Memcache vs Java Memory
问题描述
一个简单的,可能是愚蠢的问题:假设我有一个Java服务器,该服务器在内存中存储了我可以查询的常用键和值(比方说在HashMap中)
Simple, probably dumb question: Suppose I have a Java server that stores in memory commonly used keys and values which I can query (let's say in a HashMap)
与使用Memcache(甚至Redis)有什么区别?它们都将事物存储在内存中.一个或另一个有好处吗? Memcache是否会减少内存占用量?可以在更少的内存中存储更多内容吗?查询更快?没有区别吗?
What's the difference between that and using Memcache (or even Redis)? They both store things in memory. Is there a benefit to one or the other? Does Memcache leaves less of a memory footprint? Can store more in less memory? Faster to query? No difference?
推荐答案
Memcache上Java内存的优势:
Advantages of Java memory over memcache:
- Java内存速度更快(无网络).
- Java内存不需要序列化,您可以使用Java对象.
通过Java内存进行memcache的优势:
Advantages of memcache over Java memory:
- 它可以被多个应用服务器访问,因此您的缓存将在所有应用服务器之间共享.
- 可以通过各种不同的服务器访问它,只要它们都同意密钥方案和序列化即可.
- 它将丢弃过期的缓存值,因此您将获得基于时间的失效.
这篇关于Memcache与Java内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!