---
title: "There's levels to this — Kapell"
description: "Speeding up enrichment queries with a long-lived L2 cache."
canonical: "https://kapell.fm/blog/platform-l2-cache/"
published: "2026-07-05"
---

Platform July 5, 2026

# There's levels to this

And I'm heavy as it get - Meek Mill

BY THE NUMBERS PLATFORM · LIVE

API SURFACE enrichment

QUERY SPEED IMPROVEMENT A lot!

EFFECTIVE 2026-07-04

Kapell’s enrichment [pulls together many sources](https://kapell.fm/docs/how-enrichment-works/). Each one takes time to fetch. This latency cost has been offset with a per-process, in-memory [least recently used (LRU) cache](https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_(LRU)) which is lovely if a lot of people are listening to the same things, or if you never restart the API!

I expect, however, that folks will listen to a lot of different music. This will put pressure on the backend to spend a lot of time fetching data from the likes of Wikipedia over and over again. To improve performance the API now includes [hierarchy of caches](https://en.wikipedia.org/wiki/Cache_hierarchy) with the inclusion of a new Postgres-based second level (L2) cache. This cache aggressively holds slow-moving data like album intro text, avoiding a need to refetch. Caching this data both improves performance by huge margins *and* makes us a more polite client that consumes fewer of our sources… resources. Query durations to Wikipedia have a lot of variability, but the addition of this cache seems to shave a few hundreds of milliseconds — sometimes muliple *seconds*! — off enrichment queries. One of my test albums shows consistent responses in the 150ms range **with** network latency.

The downside is stale articles, but they don’t change much! We also use [negative caching](https://en.wikipedia.org/wiki/Negative_cache) to avoid re-fetching a missing resource, with a shorter TTL so we can retry sooner than we would for a positive response.

Happy enriching!

Kapell — for macOS

Press play. Meet the band.

A deeper way to play the Apple Music® library you already have — the credits, samples, and history, surfaced as the music plays. Buy it once, own the whole thing. No subscription.

[Download](https://apps.apple.com/us/app/kapell/id6779394524) [See other journal entries](https://kapell.fm/blog)
