So this is Java caching technology, you know? __ Brain College Java

Source: Internet
Author: User

One, what is the cache

1. Cache is a special memory subsystem of high speed buffer memory, which replicates frequently used data to facilitate fast access

2, usually in the speed difference between the two hardware/software, used to coordinate the difference in data transmission speed of the structure, can be called Cache

second, the classification of the cache

1, web-based application of the system architecture diagram

2, at different levels of the system architecture, in order to speed up access, there can be cached operating system disk cache-> reduce disk machinery Operations Database Cache-> reduce file system I/O application caching-> reduce query Web server caching for the database-> Reduce application server requests for client browser caching-> reduce access to Web sites

third, the operating system cache

1, the file system provides disk Cache: The operating system will often access to the contents of the file into memory, by the file system to manage

2. When the application accesses the disk file through the file system, the operating system reads the file contents from the disk cache and accelerates the file reading speed.

3, Disk Cache by the operating system to automatically manage, generally without manual intervention, but should ensure adequate physical memory to facilitate the operation of the system can use as much memory as Disk cache, speed up the file read

4, a special application of the file system disk cache has a high request, will bypass the file system disk cache, direct access to disk partitions, their own to achieve disk

5, Cache strategy Oracle RAW device (bare devices)-Directly discard the file system mysql Innodb:innodb_flush_method = O_direct

Four, the database cache

1, the importance of the database is usually the core of the enterprise application system of the most important data stored in the database is usually very large database query operations are often very frequent, and sometimes very complex causes database query can cause very frequent disk I/O read operations, forcing the CPU to suspend waiting, database performance extremely low

2. Caching policy

A, query cache with SQL as a key value caching the result set of queries as soon as the table records involved in the query are modified, the cache is automatically deleted setting the appropriate query cache will greatly improve database performance query cache not bigger the better, too big qquery Cache can waste memory. Mysql:query_cache_size= 128M

b, data buffer is the database in the memory of the container in the buffer ratio directly determines the database performance data buffer, the greater the better, the more MySQL InnoDB buffer:innodb_ Buffer_pool_size = 2G MySQL recommends buffer pool open to server physical memory 60-80%

v. Application caching

1. Object caching is provided by the O/R mapping framework such as hibernate, transparent access, fine-grained cache database query results, no business code explicit programming, is the most convenient caching strategy when the software structure according to the requirements of the O/R mapping framework for targeted design, Using object caching will greatly reduce the Web system's access to the database request good design database structure and the use of object caching, can provide very high performance, object caching for OLTP (online transaction processing) application

2, the query cache of database query result set cache, similar to the database of query cache for some time-consuming, but the timeliness of the lower requirements of the scene. Query caching and object caching are not the same scenario, they are complementary. When the table records involved in the query result set are modified, you need to be aware of cleaning up the cache

3. Page Caching

A, the role of the caching technology for the page not only can reduce the database server pressure, but also to reduce the application Server pressure good page caching can greatly improve page rendering speed page caching is the difficulty of how to clean up expired cache

B, classification

I, dynamic page static use template technology will visit the dynamic page to generate static HTML, while modifying the page link, the next request direct access static link page Dynamic page Static technology is widely used in Internet cms/news Web applications, but there are BBS applications use this technology, such as discuz! Unable to authenticate for permissions, unable to display personalization information can use AJAX requests to compensate for some of the drawbacks of dynamic page statics

II, the servlet cache is cached for page results returned by URL access, and is suitable for coarse-grained page caching, such as checks that press releases can perform permissions Oscache provides a simple servlet cache (via Web.xml configuration) You can also programmatically implement the servlet cache

III, page internal caching for dynamic pages of local fragment content caching, suitable for some personalized but not frequently updated pages (such as blog) Oscache provides a simple page cache can expand JSP tag to achieve page local cache

Vi. Web server- side Caching Web server-side caching based on proxy server mode, such as Squid/nginx Web server caching technology is used to implement CDN (content distribution network contents delivery Network) By the domestic mainstream portal site a large number of uses do not need to programming, but only limited to news release class site, the page real-time requirements are not high

Ajax -based browser caching when using AJAX calls, the database is cached in the browser-side as long as it does not leave the current page and does not refresh the current page, you can read the cached data directly only for pages using AJAX technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.