There are two main classes of cache, the read cache, and the write cache. A read cache is a tool that provides fast access to otherwise data that would otherwise be slow to access. A write cache is a tool that offers the illusion of fast write speeds, generally hiding the true slow speed of a memory device from the user.
Structure of a Cache
Typically, a cache is stored one memory tier lower than the actual data. However, data from one cache may be further cached down in the next memory tier. There are four memory tiers, with the CPU cache/registers being the lowest and fastest tier and archival storage being the highest and slowest tier. The lowest to highest tiers are CPU cache/registers, system RAM, storage drives, and archival storage.
Each step down the memory tiers offers increased access speed but reduced capacity. Most home users only have the lowest three storage tiers in the real world. Archival storage generally refers to tape storage intended for long-term and offline storage. Archival storage can also refer to the use of optical or other standard storage media that have been removed from devices and are kept offline. These examples are significantly more likely to be found in the home but are still not that common.
Note: To some degree, cloud storage could be considered a variant of archival storage. It is very much online but not necessarily accessible immediately and is generally slow to access. Removable media such as USB memory also somewhat straddle the boundary between storage drive and archival storage.
Types of Disk Cache
A disk cache refers to any cache on a “disk,” that is, storage drives such as SSDs and HDDs. There are three types of disk cache. The read cache would involve copying some data from archival storage temporarily to make access quicker while it’s needed. A write cache could take the form of an SLC cache on an SSD. An I/O cache would generally be some flash memory or DRAM used to cache both read and write operations. The defining feature of all these is that the cache is on the disk itself.
Read Disk Cache
The read cache version of a disk cache is likely the least used type of disk cache. Archival storage, by its very definition, is rarely needed. Data can also be read directly from archival media. The issue is speed. Access time is slow as the data is offline, requiring a suitable storage device to be identified and connected. Read speeds depend on the archival medium but will generally be enough for most cases. But may not be ideal for high bandwidth requirements such as high-definition video viewing. In these scenarios, a read disk cache can be used to cache a copy of the video file to a storage medium that can play it back in real-time.
Write Disk Cache
Modern SSDs are blazing fast, offering incredibly fast read and write speeds. What you might not realize is that this isn’t technically true. Most SSDs on the market are TLC, aka Triple Layer Cells. This means that each memory cell can store three bits of data. While this offers three times the storage density of raw SLC (Single Layer Cells) with one bit per cell, it’s also much slower.
Tip: TLC flash is still fast. It’s many times faster than the peak bandwidth of the SATA 3 bus used by HDDs and early SSDs. QLC flash or Quad Level Cells are even slower, in some tests actually performing slower than HDDs.
The SLC cache was invented to hide the slow write speeds from the user. SLC cache simply treats the TLC flash as SLC flash, allowing it to operate at increased speeds. Data written to the SLC cache is then internally copied to the TLC format as fast as write speeds allow. This technique works excellently, offering increasing speeds that have necessitated the development of new, faster standards.
SLC caches, however, have some caveats. The size of the SLC cache is 1/3 of the remaining free space of the SSD. As the SSD fills up, the SLC cache size decreases. This isn’t so much of a problem on large empty drives but can be on a smaller or near-capacity SSD. Once the SLC cache is filled, the user sees write speeds drop dramatically as they are exposed to the genuine TLC write speed.
Note: Technically, if data is to be written to archival media in the future, any storage disk could be regarded as a write cache for the archival media. This meaning would not generally be assumed, though.
I/O Disk Cache
HDDs are generally pretty slow, even in their optimum workloads. To help hide this from the user as much as possible, an I/O cache can be used. An I/O cache caches both read and write operations as needed. This cache is typically made up of either Flash memory or DRAM in the drive itself. Capacities are generally low, though the SSHD or Solid State Hybrid Drive class that features Flash memory offers more considerable capabilities though not comparable to modern SSD capacities.
Caching reads means that the HDD doesn’t have to find and then read the data. This can offer excellent performance benefits, but only on subsequent read operations. The first read is always slow. Caching writes means that small write operations can be absorbed to the cache and then written to the actual HDD as fast as it allows. This offers faster speeds but sees a big performance dip if the cache is ever exhausted.
An I/O cache has to carefully balance the needs of both read and write functions, especially when only a small cache is available. Larger caches somewhat negate this issue, though edge cases with large data sets can still overwhelm the flash cache of the largest SSHDs.
Note: SSDs can technically also use their onboard DRAM as an I/O cache. However, this is typically primarily or exclusively used to store the logical to physical address translation table used to find data on the SSD.
A disk cache is a cache that exists directly on a storage drive. It can take the form of a read-or-write cache or an I/O cache. Read caches typically cache data from slower, archival storage. Write caches hide the slow write speeds of storage disks from the user. I/O caches hide both slow read and slow write speeds from the user.
Caches are excellent usability tools but can cause some headaches for users when depleted. This is especially true for dynamic write caches such as the SLC cache. As non-technical users might not understand why their write speeds are so slow and thus be unable to fix them by addressing capacity issues.