Code Explainers
Code explainers tagged #caching
java
@RefreshScope @Component public class FeatureSettings {
Refreshable feature settings in Spring
caching
configuration
dependency-injection
Intermediate
7 steps
php
<?php namespace App\Resilience;
How a circuit breaker guards a flaky service
circuit-breaker
resilience
caching
Intermediate
9 steps
python
from collections import OrderedDict from typing import Any, Hashable, Optional
Building an LRU cache with OrderedDict
caching
eviction
data-structures
Intermediate
6 steps
php
<?php namespace App\Services;
Phone verification codes in Laravel
rate-limiting
caching
hashing
Intermediate
7 steps
javascript
function memoize(fn, resolver) { const cache = new Map(); function memoized(...args) {
Building a memoize wrapper in JavaScript
memoization
closures
higher-order-functions
Intermediate
7 steps
python
from functools import wraps from django.core.cache import cache from django.http import JsonResponse
Building a rate-limit decorator in Django
decorators
rate limiting
caching
Intermediate
7 steps
python
import os from dataclasses import dataclass from functools import lru_cache
Loading typed config from environment variables
configuration
environment-variables
type-coercion
Intermediate
6 steps
java
@Aspect @Component public class IdempotencyAspect {
How an idempotency aspect works in Spring
aop
idempotency
caching
Advanced
9 steps
python
from django.core.cache import cache from django.db.models import Count, Sum, Q from django.utils import timezone
Caching a Django dashboard aggregate query
caching
aggregation
conditional-queries
Intermediate
7 steps
typescript
type Fetcher<T> = (key: string) => Promise<T>; export class RequestDeduplicator<T> { private inFlight = new Map<string, Promise<T>>();
Deduplicating in-flight requests in TypeScript
deduplication
promises
caching
Intermediate
7 steps
go
package cache import ( "context"
Cache-aside reads with singleflight in Go
caching
singleflight
concurrency
Advanced
8 steps
javascript
import { NextResponse } from 'next/server' const UPSTREAM = 'https://api.exchangerate.host/latest'
A cached exchange-rate proxy in Next.js
route-handler
caching
revalidation
Intermediate
7 steps
javascript
const formatters = new Map(); function getFormatter(locale, currency) { const key = `${locale}:${currency}`;
Caching Intl.NumberFormat for currency formatting
memoization
internationalization
caching
Intermediate
8 steps
go
package web import ( "embed"
Serving embedded static assets in Go
embed
static-assets
http-handler
Intermediate
8 steps
ruby
class SearchIndexReconciler DEBOUNCE_WINDOW = 5.seconds def self.schedule(record)
Debouncing search reindex jobs in Rails
debouncing
background-jobs
caching
Advanced
7 steps
typescript
type AsyncFn<A extends unknown[], R> = (...args: A) => Promise<R>; interface MemoizeOptions<A extends unknown[]> { keyFn?: (...args: A) => string;
Memoizing async functions with TTL in TypeScript
memoization
generics
promises
Advanced
8 steps
javascript
const cache = new Map(); const inflight = new Map(); async function fetchResults(query) {
Building a typeahead with an LRU cache
caching
lru-eviction
request-deduplication
Intermediate
9 steps
python
from functools import lru_cache import math
Memoizing number theory with lru_cache
memoization
number-theory
caching
Intermediate
8 steps