zoukankan      html  css  js  c++  java
  • cache和buffer的区别

    A buffer is just a container to hold data for a short period of time when more comes in at any given time than a consumer can use / process. It's a first-in, first-out situation - the data comes in, might be buffered, and goes out in the same order it came in, after a while.

    A cache is a storage for speeding up certain operations. Things get put in a cache, and should be retrieved from it multiple times, over and over again. There's no "flowing through the cache" kind of mechanism - data doesn't come in and go out in the same order - but it's just a holding container. The order might be anything, really - items are addressed via a key, they don't "flow through" but they are "put in" and stay there (until they're thrown out because of not being used, or because the system goes down).

    buffer中的数据是一次性的,主要是处理数据的速度不如数据到达的速度,当然也有其他原因(例如标准输入输出中的buffer则考虑的是减少系统调用)

    cache则是一种需要软件和硬件配合实现的机制,用于加快数据处理速度。

    总结一下:cache主要是存放最频繁访问的数据(例如根据程序的局部性原理,使用最近最少使用算法淘汰),buffer则主要考虑的是设备间的传输速度差距。

  • 相关阅读:
    【网络】IP子网划分详解
    【java】package
    【java】异常
    【java】内部类
    【java】多态
    【java】抽象类和接口区别
    【java】接口
    Java并发编程之volatile关键字解析
    String ,StringBuffer, StringBuilder的区别
    Synchronized关键字、Lock,并解释它们之间的区别
  • 原文地址:https://www.cnblogs.com/johnnyflute/p/3542850.html
Copyright © 2011-2022 走看看