Java Cache (1, overview)

Source: Internet
Author: User

Overview

For programmers, to hear the cache, will be very excited, because of this age, you go to find work, say do not know the cache, do not use cache, are embarrassed to say that they are programmers, so that the cache is a very hot topic, today to talk about their own understanding of the cache, hope for everyone has the corresponding help.


Caching ConceptsTo learn a thing, we should first know what he is, so what is the cache? The cache is the space in memory for storing data, that is, the cache is memory. What is the purpose of caching? The cache is to optimize the program query IO data, the program frequently from the IO query data, save to memory, so that the program directly manipulate memory to obtain data, optimize the program waiting for IO data time.


classification of the cacheThere are several types of caches that can be categorized as program-centric, caching can be divided into: thread-level caching, process-level caching, out-of-process caching. The life cycle of a thread-level cache is the life cycle of a thread running a program, and the JDK provides the corresponding class, threadlocal<t>. The process-level cache generation cycle is the life cycle of the running program, the program starts, the program stops, the cache data disappears, the sun company does not provide a specific implementation, but the third party provides a lot of such frameworks, such as: Ehcache,oscache. The lifetime of the out-of-process cache is the life cycle of the cache server, and its lifecycle is completely independent of the application, and even if our application stops running, as long as our cache server is swapped for the runner, then the cached data is not lost, and after our program restarts, the corresponding cached data can still be used. There are many cache servers now, such as: redis,memcached


the difference between a cache and an object poolObject Pool This concept is not unfamiliar to everyone, if you have done and database interaction project, it will be used, that is JDBC connection pool, that is, database connection pool, the common database connection Pool framework is: C3P0,DBCP,PROXOOL,DRUID, Tomcat and other server-provided connection pool, for this part of the content you can read this blog: JDBC Database connection PoolThe above with the database connection pool simply said the concept of the pool, from the above, we can know that the object pool is also the memory of the object, the cache is, then, why do they have a different name? This is because the two are the same in their specific form, but their nature is not the same. cached objects are lightweight, generally data objects, and these objects are different, and objects in the pool object is generally manipulated objects, heavyweight objects, and are all the same, not understanding the cache of the object how is different, and later to understand that the data in the cache is different, This difference does not mean that their type or reference address is different, but that the data inside the object is different.


java cache and. NET Cache

Before learning. NET, also learned this piece of content, so, in the process of learning Java, the thinking is not a problem, the main problem is in the implementation, because, on the. NET platform, Microsoft has done a good integration, it provides a lot of aspects of the cache, such as: page cache (partial, all) , the thread cache, the process cache, and the out-of-process session cache, all provide the corresponding implementation, we just need to call on the line, do not introduce too many third-party things, but, in Java this block, it is still necessary to refer to third-party things, so, in the beginning to learn Java this piece of content, A little less accustomed, cause this because is,. NET is not open source, Java is open source, of course, open source has the problem of open source, not open source also has the advantage of not open source, again do not comment. You can view my previous blog about. NET cache stuff.


Summaryabout caching, we can use a third-party framework, or we can customize the cache, regardless of the level of cache, we can customize the implementation, after a few blog, directly use these frameworks, to do the corresponding demo.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java Cache (1, overview)

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.