---
title: "Discussion on \"Code Smell 49 - Caches\" | Hashnode"
description: "Discussion on \"Code Smell 49 - Caches\". Caches are sexy. They are a one-night stand. We need to avoid them in a long-term relationship.\n\nTL;DR: Any junior student can create a cache. Almost no senior developer can debug and invalidate them.\n\nProblems\n\nCoupling\n\nTestability\n\nCache invalidat..."
url: "https://hashnode.com/posts/code-smell-49-caches/5fd2e36a1b71d6573621af3e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Code Smell 49 - Caches](https://maximilianocontieri.com/code-smell-49-caches?utm_source=hashnode&utm_medium=feed)

Caches are sexy. They are a one-night stand. We need to avoid them in a long-term relationship. TL;DR: Any junior student can create a cache. Almost no senior developer can debug and invalidate them. Problems Coupling Testability Cache invalidat...

Dec 11, 2020 · 2 min read · maximilianocontieri.com  
Updated Feb 6, 2023  
Read the article

-   [#programming](https://hashnode.com/tag/programming)
-   [#clean-code](https://hashnode.com/tag/clean-code)
-   [#2articles1week](https://hashnode.com/tag/2articles1week)
-   [#code-smell](https://hashnode.com/tag/code-smell)
-   [#caching](https://hashnode.com/tag/caching)

## Written by

[Maxi Contieri](https://hashnode.com/@mcsee)

@mcsee · Buenos Aires

  
[View profile](https://hashnode.com/@mcsee)

Software Engineer

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.

## Responses 1

Markdown supported · ⌘↵ to post

[Manjunath Reddy](https://hashnode.com/@manjufy)

[Sep 12, 2024](https://hashnode.com/posts/code-smell-49-caches/5fd2e36a1b71d6573621af3e/comment/66e340b92ce7ef1f2788a97e)

Hey Maxi, love all the series about the Code smell :-).

Just a curious about this line `return $this->inbox->retrieveAndRemove($title);`

Here, we retrieve the title from cache and remove it immediately? Why do we retrieve and remove? Wouldn't it increase the write-to-cache ratio by deleting cache quite often :-) ? whats your thoughts on that?

[Maxi Contieri](https://hashnode.com/@mcsee)

[Sep 12, 2024](https://hashnode.com/posts/code-smell-49-caches/5fd2e36a1b71d6573621af3e/comment/66e340b92ce7ef1f2788a97e#reply-66e341c8d7174d93aa77fea1)

It is about the real life metaphore on retrieving an existing copy (and using it) If you have fungible objects (A real life book is not) you could just retrieve it and keep it. It is like aquiring a lock in this case
