All Topics  
Cache

 

   Email Print
   Bookmark   Link






 

Cache



 
 
In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, a cache is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch (owing to longer access time
Access time

Access time is the time delay or Latency between a request to an electronic system, and the access being completed or the requested data returned....
) or to compute, compared to the cost of reading the cache. In other words, a cache is a temporary storage area where frequently accessed data can be stored for rapid access. Once the data is stored in the cache, future use can be made by accessing the cached copy rather than re-fetching or recomputing the original data, so that the average access time is shorter.

A cache has proven to be extremely effective in many areas of computing because access patterns in typical computer applications
Application software

Application software is any tool that functions and is operated by means of a computer, with the purpose of supporting or improving the software user 's work....
 have locality of reference
Locality of reference

In computer science, locality of reference, also known as the principle of locality, is the phenomenon of the same value or related computer storage locations being frequently accessed....
.






Discussion
Ask a question about 'Cache'
Start a new discussion about 'Cache'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, a cache is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch (owing to longer access time
Access time

Access time is the time delay or Latency between a request to an electronic system, and the access being completed or the requested data returned....
) or to compute, compared to the cost of reading the cache. In other words, a cache is a temporary storage area where frequently accessed data can be stored for rapid access. Once the data is stored in the cache, future use can be made by accessing the cached copy rather than re-fetching or recomputing the original data, so that the average access time is shorter.

A cache has proven to be extremely effective in many areas of computing because access patterns in typical computer applications
Application software

Application software is any tool that functions and is operated by means of a computer, with the purpose of supporting or improving the software user 's work....
 have locality of reference
Locality of reference

In computer science, locality of reference, also known as the principle of locality, is the phenomenon of the same value or related computer storage locations being frequently accessed....
. There are several kinds of locality, but this article primarily deals with data that are accessed close together in time (temporal locality). The data might or might not be located physically close to each other (spatial locality).

History

Use of the word cache in the computer context originated in 1967 during preparation of an article for publication in the IBM Systems Journal. The paper concerned an exciting memory improvement in Model 85, a latecomer in the IBM System/360 product line. The Journal editor, Lyle R. Johnson, pleaded for a more descriptive term than high-speed buffer. When none was forthcoming, he suggested the noun cache, from the French
French language

French is a Romance language spoken around the world by around 80 million people as first language, by 190 million as second language, and by about another 200 million people as an acquired tongue, with significant speakers in 54 countries....
 noun meaning a safekeeping or storage place . The paper was published in early 1968, the authors were honored by IBM
IBM

International Business Machines Corporation, abbreviated IBM and nicknamed "Big Blue" , is a multinational corporation computer technology and consulting corporation headquartered in Armonk, New York, New York, United States....
, their work was widely welcomed and subsequently improved upon, and cache soon became standard usage in computer literature.

Operation


A cache is a block of memory for temporary storage of data likely to be used again. The CPU and hard drive frequently use a cache, as do web browsers and web servers.

A cache is made up of a pool of entries. Each entry has a datum (a nugget of data) which is a copy of the datum in some backing store. Each entry also has a tag, which specifies the identity of the datum in the backing store of which the entry is a copy.

When the cache client (a CPU, web browser, operating system) wishes to access a datum presumably in the backing store, it first checks the cache. If an entry can be found with a tag matching that of the desired datum, the datum in the entry is used instead. This situation is known as a cache hit. So, for example, a web browser program might check its local cache on disk to see if it has a local copy of the contents of a web page at a particular URL. In this example, the URL is the tag, and the contents of the web page is the datum. The percentage of accesses that result in cache hits is known as the hit rate or hit ratio of the cache.

The alternative situation, when the cache is consulted and found not to contain a datum with the desired tag, is known as a cache miss. The previously uncached datum fetched from the backing store during miss handling is usually copied into the cache, ready for the next access.

During a cache miss, the CPU usually ejects some other entry in order to make room for the previously uncached datum. The heuristic
Heuristic (computer science)

In computer science, a heuristic algorithm, or simply a heuristic, is an algorithm that is able to produce an acceptable solution to a problem in many practical scenarios, but for which there is no formal proof of its correctness....
 used to select the entry to eject is known as the replacement policy
Page replacement algorithm

In a computer operating system that utilizes paging for virtual memory memory management, page replacement algorithms decide which memory pages to page out when a page of memory needs to be allocated....
. One popular replacement policy, least recently used (LRU), replaces the least recently used entry (see cache algorithms
Cache algorithms

In computing, cache algorithms are Optimization instructions – algorithms – that a computer program or a hardware-maintained structure can follow to manage a cache of information stored on the computer....
). More efficient caches compute use frequency against the size of the stored contents, as well as the latencies and throughputs for both the cache and the backing store. While this works well for larger amounts of data, long latencies, and slow throughputs, such as experienced with a hard drive and the Internet, it's not efficient to use this for cached main memory (RAM).

When a datum is written to the cache, it must at some point be written to the backing store as well. The timing of this write is controlled by what is known as the write policy.

In a write-through cache, every write to the cache causes a synchronous write to the backing store.

Alternatively, in a write-back (or write-behind) cache, writes are not immediately mirrored to the store. Instead, the cache tracks which of its locations have been written over (these locations are marked dirty). The data in these locations is written back to the backing store when those data are evicted from the cache, an effect referred to as a lazy write. For this reason, a read miss in a write-back cache (which requires a block to be replaced by another) will often require two memory accesses to service: one to retrieve the needed datum, and one to write replaced data from the cache to the store.

Data write-back may be triggered by other policies as well. The client may make many changes to a datum in the cache, and then explicitly notify the cache to write back the datum.

No-write allocation is a cache policy where only processor reads are cached, thus avoiding the need for write-back or write-through when the old value of the datum was absent from the cache prior to the write.

The data in the backing store may be changed by entities other than the cache, in which case the copy in the cache may become out-of-date or stale. Alternatively, when the client updates the data in the cache, copies of that data in other caches will become stale. Communication protocols between the cache managers which keep the data consistent are known as coherency protocols
Cache coherency

In computing, cache coherence refers to the integrity of data stored in local caches of a shared resource. Cache coherence is a special case of memory coherence....
.

Applications


CPU caches


Small memories on or close to the CPU can be made faster than the much larger main memory. Most CPUs since the 1980s have used one or more caches, and modern microprocessor
Microprocessor

A microprocessor incorporates most or all of the functions of a central processing unit on a single integrated circuit . The first microprocessors emerged in the early 1970s and were used for electronic calculators, using Binary-coded decimal arithmetic on 4-bit Word ....
s inside personal computer
Personal computer

A personal computer is any general-purpose computer whose original sales price, size, and capabilities make it useful for individuals, and which is intended to be operated directly by an end user, with no intervening computer operator....
s may have as many as half a dozen, each specialized to a different part of the task of executing programs.

Disk cache


While CPU caches are generally managed entirely by hardware, other caches are managed by a variety of software. The page cache
Page cache

In computing, page cache, sometimes ambiguously called disk cache, is a "transparent" buffer of disk-backed pages kept in main memory by the operating system for quicker access....
 in main memory, which is an example of disk cache, is usually managed by the operating system kernel.

While the hard drive's hardware disk buffer
Disk buffer

In computer storage, disk buffer is the embedded memory in a hard drive acting as a buffer between the computer and the physical hard disk platter that is used for storage....
 is sometimes misleadingly referred to as "disk cache", its main functions are write sequencing and read prefetching. Repeated cache hits are relatively rare, due to the small size of the buffer in comparison to HDD's capacity.

In turn, fast local hard disk can be used to cache information held on even slower data storage devices, such as remote servers (web cache
Web cache

Web caching is the Cache of web documents in order to reduce Bandwidth usage, web server load, and perceived lag. A web cache stores copies of documents passing through it; subsequent requests may be satisfied from the cache if certain conditions are met....
) or local tape drive
Tape drive

A tape drive, which is also known as a streamer, is a computer hardware that reads and writes data stored on a magnetic tape data storage....
s or optical jukebox
Optical jukebox

An optical jukebox is a robotic data storage device that can automatically load and unload optical discs, such as Compact Disc, DVD, Ultra Density Optical or Blu-ray disc and can provide terabytes of tertiary storage....
es. Such a scheme is the main concept of hierarchical storage management
Hierarchical storage management

Hierarchical Storage Management is a Computer data storage technique which automatically moves data between high-cost and low-cost storage media....
.

Web cache


Web caches are employed by web browsers
Web browser

A Web browser is a application software which enables a user to display and interact with text, images, videos, music, games and other information typically located on a Web page at a website on the World Wide Web or a local area network....
 and web proxy servers
Proxy server

In computer networks, a proxy server is a server that acts as a go-between for requests from client seeking resources from other servers. A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource, available from a different server....
 to store previous responses from web servers
Web server

The term web server can mean one of two things:# A computer program that is responsible for accepting Hypertext Transfer Protocol requests from clients , and Server them HTTP responses along with optional data contents, which usually are web pages such as Hypertext Markup Language documents and linked objects ....
, such as web pages
Web page

A web page or webpage is a resource of information that is suitable for the World Wide Web and can be accessed through a web browser.This information is usually in HyperText Markup Language or eXtensible HyperText Markup Language format, and may provide Navigation bar to other web pages via hypertext Hyperlink....
. Web caches reduce the amount of information that needs to be transmitted across the network, as information previously stored in the cache can often be re-used. This reduces bandwidth and processing requirements of the web server, and helps to improve responsiveness
Responsiveness

The responsiveness of an interactive system describes how quickly it responds to user input . It is one of the criteria under the principle of robustness ....
 for users of the web.

Modern web browsers employ a built-in web cache, but some internet service providers
Internet service provider

An Internet service provider is a company that offers its customers access to the Internet. The ISP connects to its customers using a data transmission technology appropriate for delivering Internet Protocol datagrams, such as dial-up, DSL, cable modem or dedicated high-speed interconnects....
 or organizations also use a caching proxy server, which is a web cache that is shared between all users of that network.

Other caches

The BIND DNS
Domain name system

The Domain Name System is a hierarchical naming system for computers, services, or any resource participating in the Internet. It associates various information with domain names assigned to such participants....
 daemon caches a mapping of domain names to IP address
IP address

An Internet Protocol address is a numerical identification that is assigned to devices participating in a computer network utilizing the Internet Protocol for communication between its nodes....
es, as does a resolver library.

Write-through operation is common when operating over unreliable networks (like an Ethernet LAN), because of the enormous complexity of the coherency protocol
Cache coherency

In computing, cache coherence refers to the integrity of data stored in local caches of a shared resource. Cache coherence is a special case of memory coherence....
 required between multiple write-back caches when communication is unreliable. For instance, web page caches and client-side
Client-side

In computer networking, the term client-side refers to operations that are performed by the Client in a client-server relationship.Typically, a client is a computer application, such as a web browser, that runs on a user 's local computer or workstation and connects to a server as necessary....
 network file system
Network File System

Network File System is a network file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a computer network as easily as if the network devices were attached to its local disks....
 caches (like those in NFS or SMB
Server Message Block

In computer networking, Server Message Block operates as an Application layer mainly used to provide shared access to Computer file, Computer printer, serial ports, and miscellaneous communications between nodes on a network....
) are typically read-only or write-through specifically to keep the network protocol simple and reliable.

Search engine
Web search engine

A Web search engine is a tool designed to search for information on the World Wide Web. The search results are usually presented in a list and are commonly called hits....
s also frequently make web page
Web page

A web page or webpage is a resource of information that is suitable for the World Wide Web and can be accessed through a web browser.This information is usually in HyperText Markup Language or eXtensible HyperText Markup Language format, and may provide Navigation bar to other web pages via hypertext Hyperlink....
s they have indexed available from their cache. For example, Google
Google

Google Inc. is an United States public company, earning revenue from AdWords related to its Google search, Gmail, Google Maps, Google Apps, Orkut, and YouTube services as well as selling advertising-free versions of the Google Search Appliance....
 provides a "Cached" link next to each search result. This is useful when web pages are temporarily inaccessible from a web server
Web server

The term web server can mean one of two things:# A computer program that is responsible for accepting Hypertext Transfer Protocol requests from clients , and Server them HTTP responses along with optional data contents, which usually are web pages such as Hypertext Markup Language documents and linked objects ....
.

Another type of caching is storing computed results that will likely be needed again, or memoization
Memoization

In computing, memoization is an Optimization technique used primarily to speed up computer programs by having Subroutine avoid repeating the calculation of results for previously-processed inputs....
. An example of this type of caching is ccache
Ccache

In software development, ccache is a tool which caches the output of C /C++ compiler so that the next time, the same compilation can be omitted....
, a program that caches the output of the compilation to speed up the second-time compilation.

Database caching
Database caching

Many applications today are being developed and deployed on multi-tier environments that involve browser-based clients, web application servers and backend databases....
 can substantially improve the throughput of database
Database

A database is a structured collection of records or data that is stored in a computer system. The structure is achieved by organizing the data according to a database model....
 applications, for example in the processing of indexes
Index (database)

A database index is a data structure that improves the speed of operations on a Table . Indexes can be created using one or more column , providing the basis for both rapid random look ups and efficient access of ordered records....
, data dictionaries
Data dictionary

A data dictionary, as defined in the IBM Dictionary of Computing, is a "centralized repository of information about data such as meaning, relationships to other data, origin, usage, and format." The term may have one of several closely related meanings pertaining to databases and Database management system:...
, and frequently used subsets of data. TimesTen
TimesTen

TimesTen is a database product from Oracle Corporation. It provides a family of real-time computing infrastructure software products designed for low latency, high-volume data, event and database transaction management....
 provides a mid-tier caching facility that can be integrated into Oracle database
Oracle database

The Oracle Database consists of a relational database management system produced and marketed by Oracle Corporation. , Oracle had become a major presence in database computing....
s.

The difference between buffer and cache


The terms are not mutually exclusive and the functions are frequently combined; however, there is a difference in intent. A buffer
Buffer (computer science)

In computing, a buffer is a region of Memory used to temporarily hold data while it is being moved from one place to another. Typically, the data is stored in a buffer as it is retrieved from an input device or just before it is sent to an output device ....
 is a temporary memory location, that is traditionally used because CPU instruction
Instruction (computer science)

In computer science, an instruction is a single operation of a central processing unit defined by an instruction set architecture. In a broader sense, an "instruction" may be any representation of an element of an executable program, such as a bytecode....
s cannot directly address data stored in peripheral devices. Thus, addressable memory is used as intermediate stage. Additionally such a buffer may be feasible when a large block of data is assembled or disassembled (as required by a storage device), or when data may be delivered in a different order than that in which it is produced. Also a whole buffer of data is usually transferred sequentially (for example to hard disk), so buffering itself sometimes increases transfer performance. These benefits are present even if the buffered data are written to the buffer
Buffer

Buffer may refer to:* Buffer state, a country lying between two potentially hostile greater powers, thought to prevent conflict between them* Buffer zone, any area that keeps two or more other areas distant from one another, may be demilitarized...
 once and read from the buffer once.

A cache also increases transfer performance. A part of the increase similarly comes from the possibility that multiple small transfers will combine into one large block. But the main performance gain occurs because there is a good chance that the same datum will be read from cache multiple times, or that written data will soon be read. Cache's sole purpose is to reduce accesses to the underlying slower storage. Cache is also usually an abstraction layer
Abstraction layer

An abstraction layer is a way of hiding the implementation details of a particular set of functionality. Software models that use layers of abstraction include the OSI model for computer network Protocol , the OpenGL graphics drawing library, and the byte stream input/output model originated by Unix and adopted by MSDOS, Linux, and most ot...
 that is designed to be invisible from the perspective of neighboring layers.

See also

  • Disk buffer
    Disk buffer

    In computer storage, disk buffer is the embedded memory in a hard drive acting as a buffer between the computer and the physical hard disk platter that is used for storage....
     (Hardware-based cache)
  • Cache algorithms
    Cache algorithms

    In computing, cache algorithms are Optimization instructions – algorithms – that a computer program or a hardware-maintained structure can follow to manage a cache of information stored on the computer....
  • Cache-oblivious algorithm
  • Cache coloring
    Cache coloring

    In computer science, cache coloring is the process of attempting to allocate free page that are contiguous from the CPU cache's point of view, in order to maximize the total number of pages cached by the processor....
  • Caching failure
    Caching failure

    In computer programming, negative cache is a cache that also includes "negative" responses, i.e. failures. This means that a program remembers the result indicating a failure even after the cause has been corrected....
  • CPU cache
    CPU cache

    A CPU cache is a cache used by the central processing unit of a computer to reduce the average time to access computer storage. The cache is a smaller, faster memory which stores copies of the data from the most frequently used main memory locations....
  • Web cache
    Web cache

    Web caching is the Cache of web documents in order to reduce Bandwidth usage, web server load, and perceived lag. A web cache stores copies of documents passing through it; subsequent requests may be satisfied from the cache if certain conditions are met....
  • Data grid
    Data grid

    A data grid is a grid computing system that deals with data — the controlled sharing and management of large amounts of distributed data. These are often, but not always, combined with computational grid computing systems....