Memcache 与 Java 内存 [英] Memcache vs Java Memory

查看:33
本文介绍了Memcache 与 Java 内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的,可能是愚蠢的问题:假设我有一个 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?

推荐答案

Java 内存相对于 memcache 的优势:

Advantages of Java memory over memcache:

  1. Java 内存更快(无网络).
  2. Java 内存不需要序列化,您可以使用 Java 对象.

memcache 相对于 Java 内存的优势:

Advantages of memcache over Java memory:

  1. 它可以被多个应用服务器访问,因此您的缓存将在您的所有应用服务器之间共享.
  2. 它可以被各种不同的服务器访问,只要它们都同意密钥方案和序列化.
  3. 它会丢弃过期的缓存值,因此您会获得基于时间的失效.

这篇关于Memcache 与 Java 内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆