Skip to content

Performance Tips

Azizul Hakim edited this page Jun 12, 2025 · 1 revision

Optimize Laravel Setanjo for production environments with these essential performance strategies.

Enable Caching

Always enable caching in production:

// config/setanjo.php
'cache' => [
    'enabled' => true,
    'store' => 'redis',     // Recommended
    'ttl' => 3600,         // 1 hour
],

Environment configuration:

# Production
SETANJO_CACHE_ENABLED=true
SETANJO_CACHE_STORE=redis
SETANJO_CACHE_TTL=7200

# Development
SETANJO_CACHE_ENABLED=false

Cache Store Recommendations

Redis (Recommended)

  • Fast in-memory storage
  • Supports cache tags
  • Scales with multiple app instances

Memcached

  • Good alternative for high-performance
  • Lightweight and fast

Database Cache

  • Suitable for smaller applications
  • Use shorter TTL (1800s)

Optimization Techniques

1. Disable Validation in Production

// config/setanjo.php
'validation' => [
    'enabled' => env('APP_ENV') !== 'production',
    'throw_exceptions' => true,
],

Database Optimization

Verify Indexes

SHOW INDEX FROM settings;
-- Should include optimized indexes for performance

Use Method Chaining

// ✅ Efficient
Settings::for($user)
    ->set('theme', 'dark')
    ->set('language', 'en')
    ->set('timezone', 'UTC');

Performance Gains

With proper caching:

  • Global settings: ~10x faster (0.1-0.5ms vs 2-5ms)
  • Tenant settings: ~5x faster (0.2-1ms vs 3-8ms)
  • Bulk operations: ~10x faster (5-20ms vs 50-200ms)

Production Checklist

  • Redis/Memcached configured
  • Cache TTL optimized (3600-7200s)
  • Validation disabled in production
  • Database indexes verified
  • Batch loading implemented
  • Method chaining used

Quick Cache Commands

# Clear cache during development
php artisan setanjo:clear-cache

# Clear specific tenant cache
php artisan setanjo:clear-cache --tenant="App\Models\User:1"

# Clear all setanjo cache
php artisan setanjo:clear-cache --all

📚 Documentation Structure

Home

  • Home - Homepage of the wiki

Getting Started

Core Concepts

API Reference

Advanced Usage

  • Commands - Artisan commands for management

Tips

🤝 Community

Clone this wiki locally