TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Let’s Write a Composable, Easy-to-Use Caching Package in Python

Mike Huls
9 min readAug 29, 2024

--

Python choosing a caching strategy (image by ChatGPT + amateuristic edits by author)

In this article we’ll walk through the process of building a caching system in python from the ground up. The goal is to…

  • better understand caching and explore various caching strategies
  • understand why we went for a composition-approach over inheritance
  • learn how and when to apply a cache effectively

We’ll focus on building a user-friendly package that allows you to easily add caches to your code. Additionally, we’ll provide a simple means to extend the cache by providing it with self-designed behavior. Let’s code!

Before we begin..

This article details creating caches that are part of the the Cachr package on PyPI. All code can be found in this Github repo. Contributions are always welcome; feel free to submit bug reports, bug fixes, feature requests, documentation improvements or enhancements!

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Mike Huls
Mike Huls

Written by Mike Huls

I write about interesting programming-related things: techniques, system architecture, software design and how to apply them in the best way. — mikehuls.com

Responses (1)