10
Caching
Calvin edited this page 2013-11-14 01:37:15 +08:00
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

##Overview 缓存有几种模式,按需求灵活采用:

  • 简单的JVM内ConcurrentHashMap,而Guava的CacheBuilder还加入了LRU的最大元素限制,超时等一系列功能。
  • Ehcache这种JVM内的正式缓存实现,有更丰富的功能,而且支持集群同步。
  • Memcached这种中央式缓存,优点是无限的扩展能力,本身性能良好,缺点是有远程调用。
  • 还有一种是Memcached,NOSQL兴起前,Java世界的Data Grid曾经也很吃香。(见后)

##Details

##Data Grid 比如Spring收购的GemFire,Oracle那个天价的Coherence,JBoss替代JBossCache的Infinispan 还有Hazelcast,可以由多个JVM组成一个大的集群,比如8个JVM,各拿1G内存出来,可以组成一个复制份数是1,可failover的总容量4G的集群。 而ehcache只能做集群内容同步,无论多少服务器,client能访问的还是本地JVM上那1G的内容。

公司的项目里用HazelCast,一个土耳其公司的产品。