Interview Bank
  • Interview Bank
  • Web
    • Persistent Connection and Non Persistent
    • CDN
    • Code Review
    • JWT
      • JWT vs Session Based Authentication
      • JWT Challenge
      • JWE
      • JWS
    • Content Security Policy (CSP)
    • Same-origin Policy (SOP)
    • Cross-Origin Resource Sharing (CORS)
      • Exploiting CORS
    • HTTP Strict Transport Security (HSTS)
    • SQL Injection (SQLi)
    • Password Encryption in Login APIs
    • API Security
      • API Principles
    • Simple bypass PHP
    • Server-side Template Injection (SSTI)
    • Javascript Object and Inheritance
    • HTTP/2
    • Cookie vs Local vs session Storage
    • XML External Entity (XXE)
    • What happened when enter domain name in browser
    • Prototype Pollution - Part 1
    • Prototype Pollution - Part 2
    • Nginx vs Apache
  • OT Security
    • Securing Operational Technology: Understanding OT Security
  • Quantum Computing
    • Quantum Computing: Unveiling the Cryptographic Paradigm Shift
    • Quantum Obfuscation: Shielding Code in the Quantum Era
  • DevSecOps
    • Continuous Integration/Continuous Deployment Pipeline Security
    • Chaos Engineering Overview
      • Security Chaos Engineering
    • Mysql VS redis
    • Kubernetes (k8s)
    • How MySQL executes query
    • REDIS
    • Difference between cache and buffer
  • Windows
    • Pentesting Active Directory - Active Directory 101
    • Pentesting Active Directory - Kerberos (Part 1)
    • Pentesting Active Directory - Kerberos (Part 2)
    • AD vs Kerberos vs LDAP
    • Active Directory Certificate Services Part 1
    • Unconstrained Delegation
    • AS-REP Roasting
    • NTLM Relay via SMB
    • LLMRN
    • Windows lateral movement
    • Constrained Delegation
    • Resource-Based Constrained Delegation
    • IFEO (lmage File Execution Options) Hijacking
  • UNIX
    • Setuid
  • Large Language Models (LLMs)
    • Tokens
    • LangChain
    • Integration and Security
  • Android
    • Keystore
  • Red team development
    • Secure C2 Infrastructure
    • P Invoke in c#
    • D Invoke
    • ExitProcess vs ExitThread
  • Blue Team
    • Indicators of Compromise
    • Methods to prevent Email domain spoofing
    • Windows Prefetching
  • CVE
    • XZ Outbreak CVE-2024-3094
    • Log4J Vulnerability (CVE-2021-44228)
    • SolarWinds Hack (CVE-2020-10148)
    • PHP CGI RCE (CVE-2024-4577)
    • Windows Recall
  • Software Architecture
    • Microservices
    • KVM
  • Docker
    • Overview
    • Daemon Socket
    • Tips to reduce docker size
  • Blockchain
    • Overview
    • Smart Contract
  • Business Acumen
    • Market Research Reports and Perception
    • Understanding Acquisitions
    • Cybersecurity as a Business Strategy
  • Cyber Teams
    • Introduction to Purple Teaming
  • Malware
    • Dynamic Sandbox Limitations
Powered by GitBook
On this page
  1. DevSecOps

Difference between cache and buffer

Role of Cache

Cache is used for caching, aiming to speed up reading.

The reason for using cache is generally due to a significant speed difference between two devices, causing the resources of the high-speed device to be severely wasted, or one side expects the other side to be as fast as possible. By using an intermediate cache layer, some data that might be used can be stored temporarily, thereby reducing inefficiency and waste caused by the speed difference.

For example, the CPU's high-speed cache stores a portion of memory data, reducing the CPU waiting time caused by the speed difference between the CPU and memory. The CPU's L1, L2, and L3 caches are added due to the speed differences between layers.

Another example is caching database query results in Redis, so that the client doesn't have to retrieve this data from the slower database layer when needed.

Role of Buffer

A buffer is used to temporarily store data, accumulating a portion of continuous operations' data and then performing a complete read or write operation on the accumulated data all at once.

For example, a TCP socket has two buffer spaces: send buffer and receive buffer. When it needs to send data, it first writes the data to the send buffer to buffer it for a while. Once a certain amount of data is accumulated (or an immediate send is required), it sends out the data in the send buffer. The sent data is then buffered in the recipient's receive buffer, and the recipient monitors the receive buffer for incoming data and reads it from there.

Buffers are more efficient because the cost of multiple read or write operations is higher than the cost of completing a large read or write operation all at once.

For instance, if you use a small bucket to fetch water from a well to fill a large water tank, and the tank is far from the well, the efficiency is low because a lot of time is wasted traveling back and forth. Every trip wastes this time. In this case, using an intermediate small tank to buffer some water between the well and the large tank can improve efficiency. Once the small tank is full, you can transport the water to the large tank all at once. However, if the large tank is right next to the well, it would be more efficient to pour the water directly into the large tank each time, and adding a buffer layer would be inefficient.

For buffers, the concern is not about persistence but about when to send the data out, such as when to flush, whether to set it to sync mode, and the inefficiencies brought by flush or sync mode.

Summary

  • Cache is designed to increase the speed of reading from I/O devices and RAM by storing frequently accessed data closer to the CPU.

  • Buffer is designed to increase the efficiency of data transfer between RAM and I/O devices (like hard disks) by accumulating data and reducing the frequency of read/write operations.

Author

Ik0nw

PreviousREDISNextPentesting Active Directory - Active Directory 101

Last updated 9 months ago