performance

ruby
module MyApp
  class Application < Rails::Application
    config.load_defaults 6.1

    # Enable response compression
    config.middleware.use Rack::Deflater

API response compression with Rack::Deflater

rails performance api
by Alex Kumar 1 tab
go
package store

import (
  "context"
  "database/sql"
)

db/sql prepared statements with context and explicit Close

go sql postgres
by Leah Thompson 1 tab
ruby
class TrendingPostsService
  CACHE_KEY = 'trending_posts:v1'.freeze
  CACHE_TTL = 15.minutes

  def self.call(limit: 10)
    Rails.cache.fetch(CACHE_KEY, expires_in: CACHE_TTL) do

Redis caching for expensive computations

rails redis caching
by Alex Kumar 1 tab
java
package com.example.demo.config;

import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.caffeine.CaffeineCacheManager;

Caching strategies with Spring Cache

java spring-boot caching
by David Kumar 2 tabs
ruby
class LastSeenTracker
  THROTTLE = 5.minutes
  PENDING_KEY = "pending:last_seen".freeze

  class << self
    def touch(user_id, at: Time.current)

Database “Last Seen” without Hot Row Updates

rails performance redis
by codesnips 3 tabs
rust
use std::fs::File;
use std::io::{BufRead, BufReader, Result};

fn main() -> Result<()> {
    let file = File::open("input.txt")?;
    let reader = BufReader::new(file);

BufReader and BufWriter for efficient I/O buffering

rust io performance
by Marcus Chen 1 tab
python
from django.db import models
from django.contrib.postgres.indexes import GinIndex, BTreeIndex


class Order(models.Model):
    customer = models.ForeignKey('Customer', on_delete=models.CASCADE)

Django database indexes for query performance

django python database
by Priya Sharma 1 tab
php
<?php

use Illuminate\Support\Facades\Cache;

// Remember pattern - fetch from cache or execute closure
$posts = Cache::remember('posts.all', 3600, function () {

Laravel cache strategies for performance

laravel cache performance
by Carlos Mendez 4 tabs
java
@RestController
@RequestMapping("/api/exports")
public class ExportController {

    private final CsvStreamWriter csvStreamWriter;

Streaming a Large CSV Export in Spring Boot with StreamingResponseBody

spring-boot streaming csv
by codesnips 4 tabs
ini
; PgBouncer configuration file

[databases]
; Database connection strings
mydb = host=localhost port=5432 dbname=mydb
analytics = host=replica.example.com port=5432 dbname=mydb

Connection pooling and configuration

database connection-pooling pgbouncer
by Maria Garcia 2 tabs
php
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Resources\PostResource;

Cursor Pagination for Eloquent Queries Exposed as a JSON API in Laravel

laravel eloquent pagination
by codesnips 3 tabs
ruby
module RequestStore
  def self.store
    Thread.current[:request_store] ||= {}
  end

  def self.fetch(key)

Hot Path Memoization (within request only)

rails performance memoization
by codesnips 4 tabs