JAVA缓存框架有哪些意义呢?
PHP中文网
PHP中文网 2017-04-17 13:30:08
0
7
904

Java开源缓存框架介绍(OSCache,JSC)
OSCache是个一个广泛采用的高性能的J2EE缓存框架,OSCache能用于任何Java应用程序的普通的缓存解决方案。
有一个疑惑。就是JAVA缓存框架与memcache有什么区别呢?我把所有数据查询出来放在memcache里面不行么?比如说oscache与memcache适用场合有什么区别呢?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(7)
大家讲道理

Refer to j2cache implementation

Peter_Zhu

OSCache has not been updated for a long time. It is recommended to read the official documentation of EHCache.

There are obvious differences between

ehcache, a jvm cache, and memcache, a io-level cache. The following differences determine their use in different scenarios.
优点: It will be more efficient without IO overhead and more flexible to use.
缺点: However, the public jvm memory will also have an impact on the application itself, and it will be more difficult to share it with multiple applications. (ehcache has a solution that does not use jvm memory)

伊谢尔伦

OSCache or EHCache, the main application scenarios are mostly in-application caching. That is the cache used in my program. All caches are in this program written by myself.
Memcache is an independent process and an independent cache. The cached data is saved in the memory of another process. In my opinion, there are two differences:

  1. The cache in an application like EHCache is not easy to share between multiple instance applications. For common web applications, when it is necessary to start multiple instances to enhance processing capabilities, the inability to share the cache is not conducive to cache hits.
  2. memcache is an independent cache that will not be affected by the startup or stop of the application. In web applications, program restart is a very common thing. If you use the in-app cache, once the program is restarted, all caches will be lost (of course, the default refers to the case where persistence support is not turned on).
Peter_Zhu

Personally, I feel that memcache is similar to a container for objects. It only provides simple functions of putting objects in and removing objects. It can be imagined as a Map.
OSCache is encapsulated on the basis of this kind of object container, providing more powerful functions. It can realize automatic caching of some content through simple configuration files. However, using memcache directly requires writing a lot of additional caching logic and strategy code. .

大家讲道理

Using caching, for example, caching some fixed master data, it is very easy to improve website performance by 5-10 times. We use EHCache to easily improve the performance of a course selection system by 7-8 times.

When using cache, the most troublesome thing is dealing with data synchronization. For example, with a redis cache server and a mysql server, you can write data to two databases at the same time, but there will be problems with transaction processing. Cache synchronization is still quite troublesome

Ty80

OSCache or EHCache is a JVM cache. It cannot be shared by multiple applications or your cluster. This will cause a waste of memory and is suitable for small applications that do not require a cluster. Memcache is an independent cache that can be shared by a cluster or multiple applications. It is suitable for larger applications.

洪涛

OSCache or EHCache are often used for server local cache. If used directly, it can only be accessed by a single application process. If multiple processes are opened or multiple servers are deployed, each process can only access the local cache. If caching is needed Synchronization requires writing relevant synchronization code. ehcache also supports distributed caching of RMI, JGroups, and JMS, so there is no need to write synchronization code by hand. You can also build a separate EhCache Server, which is almost the same as memcache.

The memcache cache is a separate process. The advantage is that there is less cache synchronization between processes, because there is only one copy of the data on memcache, instead of ehcache having one copy on each process; but access requires inter-process communication, which is more communication overhead.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template