Understanding Caching in Python

By Chirag Shah

Elevator Pitch

In this talk, I am going to talk about advanced concepts of Python related to Caching. I will describe in depth the different methods of Caching, their pros and cons. This talk will help developers focus on their code before scaling their applications.

Description

In this talk, I am going to talk about advanced concepts of Python related to Caching.


A cache can be easily understood as a saved answer to a question. Caching can speed up an application if a computationally complex question is asked frequently. Instead of the computing the answer over and over, we can use the previously cached answer.

Caching is an important component while scaling applications which are to be used by many users. It solves various problems related to cost and latency. Usually it takes more time to retrieve data from DB rather than cache. Using a cache to avoid recomputing data or accessing a slow database provides us with a great performance boost.

I will describe in depth the different methods of Caching, their pros and cons. This talk will help developers focus on their code before scaling their applications. It will provide immense performance improvements with this simple concept.

Outcomes: The novice audience will be able to understand basic Caching Mechanisms. They will be able to utiilize their knowledge which will serve pivotal while scaling applications


Contents to be covered in talk:

  1. Local Caching: What is it, how to do it, example, built-in Python libraries: (using cachetools), advantages, dis-advantages

  2. Memoization: What is it, pseudo-code algorithm, implementation using example, built-in Python libraries: (using lru_cache), advantages, dis-advantages

  3. Distributed Caching: What is it, techniques: (using memcached, using pymemcache)


Agenda:

  • Initial 10 minutes: Introduction to Caching and its various techniques.
  • 10 - 20 minutes: Examples and code walk through for various techniques.
  • 20 - 25 minutes: Comparative analysis of how caching is better than non-scaled applications.
  • 25 - 30 minutes: Q&A session