📖
System Design
  • Home
  • Learn System Design Daily
  • System Design Steps
  • List of design questions:
  • My System Design Interview Checklist
  • CheatSheet
  • Programming Language Jargons
  • Scaleable Design
  • Agile Scrum
  • Uber
  • Gmail System Design
  • Distributed Rate Limiting
  • Audio Search Engine
  • Code Style and Review
  • Calling App Design
  • Low Level Design: Payment Tracking App
  • Machine Coding :Cache
  • Interview Advice
  • URL Shortner
  • Unique ID in Distributed Systems
  • Load Balancing Algorithm
  • API Architecture
  • Desgin Practise for Rest API
  • Performance Practise for API
  • API Gateway
  • API Security Hacks
  • Distributed Design Patterns
  • Fault Tolerance in Distributed Systems
  • Microservice Communication Design Patterns
  • Zipping /Compression
  • Database
  • Mongo DB
  • SQL
  • PostgreSQL
  • Database Designs
    • Designing a location based database
  • Building Database
  • Design Patterns
    • Microservice Architecture 10 Design Patterns
    • Interaction Patterns
  • Locale.ai
  • Version Control
  • Caches / Caching
  • High Level Design
  • Low Level Design
  • Containers, Docker
  • Docker
  • Linux Directories
  • Design Pattern for Software Architect
  • S.O.L.I.D Principles
  • Monitoring and Telemetry for Production System
  • C4 model
  • LRU Cache
  • VSCode
  • Chatbot Architecture
  • Streaming API Repsonse
  • Latency in System Design
  • Cloud
    • Azure
    • AWS
  • Builds
    • Jenkins
Powered by GitBook
On this page

Was this helpful?

Machine Coding :Cache

LLD designs are of two types: Machine coding where you actually build something. And 'Design' where you mention the classes and inheritance/composition relations.

Machine coding is similar to HLD where you clarify requirements of the object you are building, and then move on to code it. It requires some show to executable code.

  1. Readability

    1. First draw the interaction diagram, and make sure the requirements are clear. You first tell what you'll do, then code it.

    2. Walk your interviewer through the code while you write it.

    3. Clarify requirements as you go along.

    4. Don't refrain from using the board. It's better to invest 2 minutes for a smooth flow.

  2. Correctness

    1. Before you write a major function, define what it does.

    2. Set 1-2 tests for every major function. This makes you confident of correctness. Try to make the tests runnable (even some examples running in the main function help).

    3. Is concurrency an issue? Most of these cases can't be tested in the limited time, so try to remove such issues. Can you use ordering? Code locks? Data Locks?

    4. Pick one feature at a time. Write a test to confirm.

  3. Performance

    1. Look for bottlenecks in your code. You need to be very familiar with time complexities. Code with O(n^2) time complexity is not acceptable.

    2. Most performance problems related to search can be solved using inverse mapping or priority queues. Look at how a map and queue can work together.

Tips:

a) Clarify requirements

b) Code in a structured manner and talk them through the process

c) Attack the most critical parts first.

We define the engineering requirements of the cache, using the CRUD model.

An in depth explanation of ordering and read/write guarantees.

PreviousLow Level Design: Payment Tracking AppNextInterview Advice

Last updated 4 years ago

Was this helpful?

Cache Write Policies:

Cache replacement policies of LRU and LFU:

Distributed Caching Video:

Generics:

https://en.wikipedia.org/wiki/Cache_(computing)#Writing_policies
https://en.wikipedia.org/wiki/Cache_replacement_policies
https://www.youtube.com/watch?v=U3RkDLtS7uY
https://docs.oracle.com/javase/tutorial/java/generics/why.html