Integration of SSM framework ehcache

This article focuses on integrating ehcache with SSM framework. Someone may ask what ehcache is.

About the introduction, advantages and disadvantages of ehcache, I think the following answers are enough for readers to understand:

Ehcache is a pure Java in-process caching framework, which is fast and lean. It is the default cacheprovider in hibernate. Ehcache is a widely used open source Java distributed cache. It is mainly aimed at general cache, Java EE and lightweight container. It has the characteristics of memory and disk storage, cache loader, cache extension, cache exception handler, a gzip cache servlet filter, support for rest and soap API.

Advantages: 1 Fast 2 Simple 3 Multiple caching strategies 4 There are two levels of cached data: memory and disk, so there is no need to worry about capacity. 5 Cache data will be written to disk during virtual machine restart 6 Distributed caching can be implemented through RMI, pluggable API, etc. 7 Listening interface with cache and cache manager 8 Support multiple cache manager instances and multiple cache areas of an instance 9 Provide cache implementation of Hibernate

Disadvantages: 1 When using disk cache, it takes up a lot of disk space: This is because the algorithm of diskcache is simple, which also leads to high efficiency of cache. It simply appends storage directly to the element. Therefore, the search for elements is very fast. If diskcache is used, the disk will soon be full in frequent applications. 2. Data security cannot be guaranteed: when Java is suddenly killed, conflicts may occur. The solution of ehcache is to rebuild the cache if the files conflict. This may be unfavorable when cache data needs to be saved. Of course, cache is only a simple acceleration, but can not ensure the security of data. If you want to ensure data storage security, you can use bekeley DB Java Edition. This is an embedded database. Can ensure storage security and space utilization.

Perhaps some people are confused about cache. What is cache? Why cache?

Quote Baidu Encyclopedia's answer:

Cache is a buffer for data exchange (called cache). When a hardware wants to read data, it will first find the required data from the cache. If it is found, it will be executed directly. If it cannot be found, it will be found from memory. Since the running speed of cache is much faster than that of memory, the function of cache is to help the hardware run faster.

Because the cache often uses RAM (non permanent storage after power failure), the files will still be sent to the hard disk and other memory for permanent storage after use. The largest cache in the computer is the memory module, and the fastest is the L1 and L2 cache embedded in the CPU. The video memory of the graphics card is the cache for the graphics card computing chip, and there is also 16m or 32m cache on the hard disk.

Maybe someone will ask what memory is?

Quote Baidu Encyclopedia's answer:

Memory is one of the important components in computer, and it is the bridge to communicate with CPU. All programs in the computer run in memory, so the performance of memory has a great impact on the computer. Memory, also known as memory, is used to temporarily store the operation data in the CPU and the data exchanged with external memory such as hard disk. As long as the computer is running, the CPU will transfer the data to the memory for operation. When the operation is completed, the CPU will transfer the results. The operation of the memory also determines the stable operation of the computer. Memory is composed of memory chip, circuit board, golden finger and so on.

Maybe someone will scold me and say how you can quote Baidu Encyclopedia.

My answer is, because I don't know how to answer it.

If you ask me why caching is needed in development and its role, my answer is that for some data, I only need to query once, and I don't need to query again, because there is caching. Just like database optimization, in addition to indexing, there is also caching the data in the database. In this way, for large-scale data, it usually needs multiple queries, resulting in long time-consuming and poor performance. However, I only need to query once through caching. When I query again, it is very fast and will have no impact on the response and performance of the whole system. Of course, when there are differences between the cached data and the data in the actual database, we will talk about how to solve this problem later.

In addition, it is suggested that friends of software development should be familiar with computer related theoretical knowledge when they have time. As the saying goes: all changes are inseparable from their religion. In the computer, it can be understood as algorithm and data structure, operating system, TCP / IP, basic computer knowledge, compilation principle and so on. Grasp these, the road of programming can be longer and longer.

This is what a friend told me.

Let's move on to the topic of integrating ehcache with SSM framework

SQL script preparation

1、 Import Maven dependencies

3、 Write Dao

7、 Write XML corresponding to Dao

UserDao. xml

spring-mvc. xml

config. properties

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>