Reputation: 4820
I read about JSR 107 Caching (JCache).
I'm confused: From what I know, every CPU manage his caching memory (without any help from OS).
So, why do we need Java Caching handler ? (if the CPU manage his own cache)
What I miss here ?
Thanks
Upvotes: 1
Views: 471
Reputation: 13420
There is a difference between CPU caching and memory caching. This JCache would cache things in memory so you don't have to get it from an expensive resource like disk or over the network.
So CPUs have caches built into them so that they can avoid going to memory. CPUs commonly have three levels of cache and store around 8MB. CPU caching is not something you have to worry about because it is taken care of for you. If something isn't in the CPU cache then it has to go fetch it out of memory.
Caching in memory is to avoid going to disk or even slower resources as I mentioned earlier. This mechanism programs have control over. So if you want to avoid continously asking your DB for some object you can store it memory and keep returning the same object. This saves quite a bit of performance. As Thomas mentioned JCache adds the functionality to be able to provide caching across JVMs. From what I understand this means that different Java programs can share the same cache.
Upvotes: 1
Reputation: 3045
This is about caching Java objects, like objects that are expensive to create, or need to be shared between multiple Java VMs. See https://jcp.org/en/jsr/detail?id=107
A cache is generally used to temporarily keep data between uses because it takes too much time or is plain impossible to recreate if you just throw it away between uses.
The CPU cache keeps data and instructions in case it has to access it again, because reading it from memory takes more time.
The JSR 107 cache works o a completely different level.
Upvotes: 2