Firstly I would like to tell that I come from a non-Computer Science background & I have been learning the C++ language.
I am unable to understand what exactly is a cache?
It has different meaning in different contexts.
I would like to know what would be called as a cache in a C++ program?
For example, if I have some int
data in a file. If I read it & store in an int
array, then would this mean that I have 'cached' the data?
To me this seems like common sense to use the data since reading from a file is always bad than reading from RAM.
But I am a little confused due to this article.
In a CPU there can be several caches, to speed up instructions in loops or to store often accessed data. These caches are small but very fast. Reading data from cache memory is much faster than reading it from RAM.
It says that reading data from cache is much faster than from RAM. I thought RAM & cache were the same. Can somebody please clear my confusion?
EDIT: I am updating the question because previously it was too broad. My confusion started with this answer. He says
RowData and m_data are specific to my implementation, but they are simply used to cache information about a row in the file
What does cache in this context mean?