PCEVA,PC绝对领域,探寻真正的电脑知识
12
返回列表 发新帖
打印 上一主题 下一主题
开启左侧

【原创】我来说说,到底什么是“缓存”

  [复制链接]
21#
yanleiberg 发表于 2012-6-5 01:02 | 只看该作者
SnowGround 发表于 2012-6-1 19:23
晕倒,buffer和cache。

cache是指硬件,物理概念。buffer是指需要使用缓存的程序在硬件里申请的一片连续的 ...


那请问光驱硬盘打印机里的自带的缓存难道不叫buffer?难道是用户可控制的?
编程领域里的buffer只是buffer一种,并不是所有。
22#
haierccc  楼主| 发表于 2012-6-15 17:17 | 只看该作者
我认为这种不可控制的缓存,的确不应该叫Buffer,而应该叫cache。
23#
黯淡的风 发表于 2012-6-15 18:30 | 只看该作者
学习了 绑定
24#
danielmiao 发表于 2012-6-25 22:10 | 只看该作者
本帖最后由 danielmiao 于 2012-6-25 22:13 编辑

Buffer是编程时候提高程序效率设的缓冲区,Cache是硬件中间的缓寸,完全没有研究的意义
25#
dlsuki 发表于 2012-6-26 07:56 | 只看该作者
buffer:
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 (such as a keyboard) or just before it is sent to an output device (such as a printer). However, a buffer may be used when moving data between processes within a computer. This is comparable to buffers in telecommunication. Buffers can be implemented in either hardware or software, but the vast majority of buffers are implemented in software. Buffers are typically used when there is a difference between the rate at which data is received and the rate at which it can be processed, or in the case that these rates are variable, for example in a printer spooler.


cache:
In computer science, a cache (pronounced /ˈkæʃ/, like "cash" [1]) 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) 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. Cache, therefore, helps expedite data access that the CPU would otherwise need to fetch from main memory.

也就是说当你把数据写入目标设备时,需要考虑这个设备的单位时间内的数据接受能力和处理能力, 如果接受能力大于处理能力的话, 就有必要加个buffer来缓冲下.
cache是用来临时存放经常需要读取的数据的地方, 它的访问速度通常要快于保存这些数据的设备, 所以把这些数据预读到cache里能提高访问速度.
其实buffer和cache有时候也是结合在一起用的, 比如数据库的buffer pool, 这里面的数据最终是要被写到数据文件里面,从这方面说它是buffer.这个里面的数据也可以被其他的进程访问, 以提升读取速度, 从这方面看又有cache的应用了.
26#
a315344690 发表于 2012-6-27 17:10 | 只看该作者
技术贴,学习一下,只知道cache是缓存
27#
SnowGround 发表于 2012-6-28 07:52 | 只看该作者
光驱硬盘打印机里面的硬件当然只能叫Cache,你没开机,没上电,它永远只能叫Cache

开了机上了电,映射了地址可供访问了。它还是叫Cache。
你把它申请下来准备往里面填数据了,你申请下来的这部分空间就是你的Buffer。整个硬件还是叫Cache。
做完事你把它释放了。你的Buffer就没了。而Cache还是Cache,它物理存在在那里。

这是我的看法。楼下继续。
28#
haierccc  楼主| 发表于 2012-7-24 22:11 | 只看该作者
很久没来了,我顶一下,呵呵
29#
thenero 发表于 2012-7-25 16:05 | 只看该作者
以下文字引用字:http://tech.ddvip.com/2007-09/119026496435105.html 致谢

  buffer 与cache 的区别

  A buffer is something that has yet to be "written" to disk. A cache is something that has been "read" from the disk and stored for later use.

  更详细的解释参考:Difference Between Buffer and Cache


  cache 和 buffer的区别:

  Cache:高速缓存,是位于CPU与主内存间的一种容量较小但速度很高的存储器。由于CPU的速度远高于主内存,CPU直接从内存中存取数据要等待一定时间周期, Cache中保存着CPU刚用过或循环使用的一部分数据,当CPU再次使用该部分数据时可从Cache中直接调用,这样就减少了CPU的等待时间,提高了系统的效率。Cache又分为一级Cache(L1 Cache)和二级Cache(L2 Cache),L1 Cache集成在CPU内部,L2 Cache早期一般是焊在主板上,现在也都集成在CPU内部,常见的容量有256KB或512KB L2 Cache。

  Buffer:缓冲区,一个用于存储速度不同步的设备或优先级不同的设备之间传输数据的区域。通过缓冲区,可以使进程之间的相互等待变少,从而使从速度慢的设备读入数据时,速度快的设备的操作进程不发生间断。

  Free中的buffer和cache:(它们都是占用内存):

  buffer : 作为buffer cache的内存,是块设备的读写缓冲区

  cache: 作为page cache的内存, 文件系统的cache

  如果 cache 的值很大,说明cache住的文件数很多。如果频繁访问到的文件都能被cache住,那么磁盘的读IO bi会非常小
30#
thenero 发表于 2012-7-25 16:09 | 只看该作者
通俗的来讲buffer是傻交换负责把数据中转后发向目的地,cache是互联网加速器,先查询下有无数据有数据本地调用无数据访问互联网。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部