I know that a cache is used to improve the speed of reading data from hard drive because the speed of reading data from hard drive and the speed of reading data from RAM are very different. So the index of cache miss is very important.
Also, I know that we have the buffer (for example, there are BufferedWriter
and BufferedReader
in Java) while reading from and writing to the hard drive or other devices such as keyboard. But I don't know why we need a buffer. What if we have no buffer? Is the buffer also for improving reading speed? If so, what is the difference between buffer and cache?
Besides, I know that cache is to improve the reading speed but can cache improve the speed of writing data from RAM to hard drive?