简体   繁体   中英

What's the difference between "cache" and "data store"?

I'm trying to discern the difference between the two, however the terms seem to be used interchangeably in various places.

I see the term "cache" is most commonly used when talking about saving files for later, such as browser caching.

Whereas the term "data store" tends to be used strictly for things such as text, arrays, database values etc...

Have I just answered my own question? I'm not sure...

I work mostly with PHP, so any examples in PHP would be helpful but not required.

Thanks!

PHP is a server-side scripting language. Other server-side languages are NodeJS, Python, Java, etc. Similaryly, there are client-side programming languages such as Javascript, etc.

In web development, a client (lets say a browser) issues a request (for eg, to see if an item is available on an e-commerce website). The request goes to the server and the server looks up this data in a database. Usually, the database stores this data on disk. Usually, this retrieval of data from the database is the most time-taking operation in the entire communication; and the client (the browser) is waiting until the server returns with the response. To make this communication faster, caches are implemented to store most frequently used data in the memory. Since retrival of data from memory is much faster (less than 1 ms), the server immediately responds to the request with the data.

The above is an example of a cache that is implemented on server-side. Similarly, developers can implement a cache on the client-side (for eg, browser cache). Since the cache is in memory (RAM), this data is volatile and transient.

Data store is a term that is basically used to represent persistent data in any form, such as database, files, emails, etc. In the above example, cache is volatile while the database that stores the data on the disk can be called as data store.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM