- stevencodes.swe
- Posts
- stevencodes.swe - September 14, 2025
stevencodes.swe - September 14, 2025
Dev tool recs, weekly video highlight
đź‘‹ Hey friends,
Here’s what I’ve got in store for you this week:
Snippet from Chapter 4 of The Backend Lowdown
Weekly Video Highlight: CLI Showdown Pt. 2
Dev tool recommendations
Let’s get into it 👇
The Backend Lowdown: Chapter 4 Preview
Every newsletter will include a snippet from my book in progress, The Backend Lowdown, available for $1 right now on Gumroad!
Get The Backend Lowdown →Bust-on-Write (keep cache-aside correct)
With cache-aside, your cache only updates when there's a miss - it doesn't know when the underlying data changes. To handle updates correctly, your write path needs to delete (or "bust") the affected cache keys, forcing the next read to fetch fresh data and repopulate the cache.
When it helps
You want users to see their changes immediately but prefer to keep your read path simple (pure cache-aside)
You have derived caches (product lists, search indexes, count aggregates) that become stale when individual items change
Your data is read frequently but written occasionally, making invalidation cheaper than constant updates
Here are 3 ways to go about implementing bust-on-write:
Newsletter note: only showing one example here
2. Collection "version bump" (tagless, scalable invalidation)
Instead of tracking and deleting every possible list key, embed a version number in your list cache keys. When data changes, increment the version. This instantly makes all old cached lists unreachable without having to find and delete them.
Read Path
def list_key_for_category(category_id, page:)
ver = category_version(category_id)
"v3:products:category:#{category_id}:ver:#{ver}:page:#{page}"
end
​
def category_version(category_id)
# Start at version 1 if no version exists yet
(Rails.cache.read(category_version_key(category_id)) || 1).to_i
end
​
def category_version_key(category_id)
"v:category:#{category_id}"
endWrite Path
after_commit do
Rails.cache.delete_multi(entity_keys) # Still bust individual product keys
bump_category_version!(category_id) # Invalidate ALL lists for this category
end
​
def bump_category_version!(category_id)
# Use atomic increment if your cache supports it (Redis/Memcached do)
# Note: Rails.cache.increment behavior varies by adapter
redis.incr(category_version_key(category_id))
rescue => e
Rails.logger.warn("version bump failed: #{e.class}: #{e.message}")
# Fallback: write current timestamp (still invalidates, just not as clean)
Rails.cache.write(category_version_key(category_id), Time.now.to_i)
endWhy it's powerful
You don't need to track or enumerate every list key, just bump the version and they're all instantly stale
Old cached lists naturally expire via TTL without manual cleanup
Scales to unlimited list variations (different pages, filters, sorts)
Weekly Video Highlight: CLI Showdown Pt. 2
This week I continued looking for some neat CLI tools. The most popular video from this week was all about dealing with JSON efficiently. I’m going to go more in depth on this below, but if you’d like to see the video here it is:
@stevencodes.swe Stop eyeballing logs. This trio turns raw text into structured data you can navigate and script. Use jc to convert, jq to process, and fx ... See more
Dev Tool Recommendations: JSON Power Trio
Most CLI output is made for humans, not scripts. This trio flips that: jc converts text → JSON, jq processes JSON, and fx lets you explore JSON interactively. Together, they turn ad-hoc shell work into repeatable commands you can trust.
jc - Convert anything to JSON
What it is: A converter that parses the output of common commands (ps, netstat, ifconfig, dig, df, etc.) into structured JSON.
Why it’s helpful: Once it’s JSON, you can filter, sort, group, and automate; no brittle column parsing.

Looking up process ids, their corresponding executables, and their RSS
jq - Process JSON at the speed of thought
What it is: A fast, composable JSON processor (think awk/sed, but for JSON).
Why it’s helpful: Turns “eyeballing logs” into one-liners you can paste into scripts or runbooks.

Looking up the top 5 memory hogs. Surprise, surprise…
fx - Explore JSON when you don’t know the shape
What it is: An interactive JSON viewer + JavaScript REPL in your terminal.
Why it’s helpful: Perfect for discovery. Navigate with arrows, search with /, jump by path with ., and press P to print just the subtree you want (to save or pipe onward).

Looking through various utm sources
That’s a wrap for this week. If something here made your day smoother, feel free to reply and tell me about it. And if you think a friend or teammate would enjoy this too, I’d be grateful if you shared it with them.
Until next time,
Steven


