Code Explainers

Code explainers tagged #cache-invalidation

php
<?php
 
namespace App\Cache;
 

A content-hashed fragment cache in PHP

caching content-hashing atomic-writes
Intermediate 10 steps
ruby
module ProductsHelper
  def cached_product_row(product)
    cache [product, current_user.role] do
      render partial: "products/row", locals: { product: product }

Russian doll caching that busts itself in Rails

fragment-caching cache-invalidation associations
Intermediate 4 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
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
java
@Service
public class ProductCatalogService {
 
    private final ProductRepository productRepository;

How Spring cache annotations keep data fresh

caching cache-invalidation dependency-injection
Intermediate 7 steps