Code Explainers
Code explainers tagged #caching
php
<?php namespace App\Services;
Caching per-tenant settings in Laravel
caching
multi-tenancy
dependency-injection
Intermediate
7 steps
php
<?php namespace App\Http\Middleware;
Idempotency keys in Laravel middleware
idempotency
middleware
caching
Advanced
8 steps
typescript
type CurrencyFormatOptions = { locale?: string; currency: string; showDecimals?: boolean;
Caching Intl.NumberFormat for currency
memoization
internationalization
caching
Intermediate
9 steps
php
<?php namespace App\Models;
Debouncing Eloquent jobs in Laravel
debounce
model-events
queued-jobs
Advanced
7 steps
php
<?php namespace App\Services;
Tagged cache invalidation in Laravel
caching
cache-tags
invalidation
Intermediate
5 steps
javascript
const crypto = require('crypto'); function inMemoryCache({ maxAge = 60_000, maxEntries = 500 } = {}) { const store = new Map();
Building an in-memory cache middleware in Express
caching
middleware
etag
Advanced
10 steps
ruby
class DashboardMetrics CACHE_TTL = 15.minutes def initialize(account)
Caching dashboard metrics in Rails
caching
service-object
query-optimization
Intermediate
5 steps
ruby
class LRUCache def initialize(capacity) raise ArgumentError, "capacity must be positive" unless capacity.positive?
How an LRU cache works in Ruby
caching
eviction
hash-ordering
Intermediate
7 steps
python
import json import hashlib from datetime import timedelta
Idempotent payment endpoints in FastAPI
idempotency
redis
distributed-locking
Advanced
9 steps
php
<?php namespace App\Http\Middleware;
Idempotent requests with Laravel middleware
idempotency
middleware
caching
Advanced
8 steps
python
from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector from django.core.cache import cache from django.db.models import F from django.http import JsonResponse
Ranked full-text search in Django
full-text-search
debouncing
caching
Advanced
9 steps
go
func ServeVideo(c *gin.Context) { id := c.Param("id") video, err := videoRepo.FindByID(c.Request.Context(), id) if err != nil {
Streaming video files with Gin
http streaming
range requests
file serving
Intermediate
6 steps
php
<?php namespace App\Cache;
A content-hashed fragment cache in PHP
caching
content-hashing
atomic-writes
Intermediate
10 steps
typescript
import { Injectable, OnModuleInit, Logger } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Cron, CronExpression } from '@nestjs/schedule';
A self-refreshing feature flags provider in NestJS
caching
scheduled-tasks
dependency-injection
Intermediate
8 steps
php
<?php namespace App\View\Composers;
How a Laravel view composer feeds the navigation
view-composer
caching
dependency-injection
Intermediate
5 steps
go
package middleware import ( "bytes"
Building a response cache middleware in Gin
middleware
caching
concurrency
Intermediate
8 steps
python
from flask import Blueprint, jsonify, request, abort from flask_caching import Cache cache = Cache(config={"CACHE_TYPE": "RedisCache", "CACHE_REDIS_URL": "redis://localhost:6379/0"})
Custom cache keys for Flask endpoints
caching
redis
cache-invalidation
Intermediate
7 steps
go
package server import ( "net/http"
Serving cached static assets in Gin
caching
static-files
middleware
Intermediate
7 steps