Cache Sistemleri

Memcache vs Response Cache vs Redis

Farklari, Kullanim Alanlari ve Performans Karsilastirmasi

Basit Anlatim (Herkes Icin)

Cache sistemlerini bir restoran mutfagi gibi dusun:

🥘

Redis / Memcache

Mutfakta hazir malzemeler. Sogan dogranmis, sos hazir. Her siparis icin sifirdan baslamiyorsun.

🍽️

Response Cache

Komple hazir yemek. Musteriye direkt servis. Mutfaga bile girmeye gerek yok!

📋

Query Cache

Tarif defteri. Ayni tarifi her seferinde kitaptan okumak yerine ezberden yapiyorsun.

Detayli Karsilastirma

Ozellik Redis Memcache Response Cache
Ne Cache'ler? Query sonuclari, objeler, session, her sey Query sonuclari, objeler, session Tum HTTP response (HTML)
Seviye Uygulama icinde (kod seviyesi) Uygulama icinde (kod seviyesi) HTTP seviyesi (sayfa tamamı)
PHP Calisir mi? Evet, her istekte Evet, her istekte HAYIR! Direkt cache'den
Hiz Kazanci %50-80 (query azaltir) %50-80 (query azaltir) %95-99 (PHP bile calismaz!)
TTFB Ornek 500-800ms 500-800ms 50-100ms
Veri Yapilari String, List, Set, Hash, Sorted Set Sadece String (key-value) HTML string
Persistence Var (RDB, AOF) Yok (RAM only) Storage'a bagli
Cluster Native destek Consistent hashing Storage'a bagli
Pub/Sub Var Yok Yok

Redis

Avantajlar:

  • Zengin veri yapilari (list, set, hash, sorted set)
  • Persistence - sunucu restart'ta veri korunur
  • Pub/Sub - real-time mesajlasma
  • Lua scripting destegi
  • Native cluster destegi
  • Transaction destegi

Dezavantajlar:

  • Memcache'e gore biraz daha yavas (micro-benchmark'ta)
  • Daha fazla RAM kullanimi (metadata icin)

Memcache

Avantajlar:

  • Cok basit ve hizli
  • Dusuk memory overhead
  • Multi-threaded (Redis single-threaded)
  • Basit key-value islemleri icin ideal

Dezavantajlar:

  • Sadece string veri tipi
  • Persistence yok - restart'ta veri kaybolur
  • Pub/Sub yok
  • Native cluster yok
  • Max value size: 1MB

Response Cache (Full Page Cache)

Nasil Calisir?

  1. Kullanici sayfa ister (GET /)
  2. Middleware cache'i kontrol eder
  3. Cache varsa: PHP bile calismaz, direkt HTML doner
  4. Cache yoksa: Normal render, sonra cache'e yaz

Ne Zaman Kullanilir?

  • Statik veya yavas degisen sayfalar
  • Guest kullanicilar icin ana sayfa
  • Blog, urun listesi, kategori sayfalari
  • SEO sayfalari

Ne Zaman KULLANILMAZ?

  • Admin paneli
  • Dashboard (kullaniciya ozel)
  • Sepet / Checkout
  • Login / Register
  • Favoriler / Playlist'lerim
  • Odeme callback'leri
  • POST/PUT/DELETE istekleri

Performans Farki:

800ms Redis Cache
50ms Response Cache
16x Hizli!

Muzibu.com.tr Mevcut Durum

Redis Cache

AKTIF

Session, Queue, App Cache

Response Cache

KAPALI

Settings'ten kapatilmis

Memcache

KULLANILMIYOR

Redis tercih edildi

Oneri:

Response Cache'i aktif et! Guest kullanicilar icin sayfa yuklemesi 800ms'den 50ms'ye dusecek. Auth kullanicilar, admin, cart, checkout gibi sayfalar otomatik olarak cache'lenmez (guvenli).

Sonuc ve Oneriler

1

Redis Kullanmaya Devam Et

Memcache'e gecmeye gerek yok. Redis daha zengin ozellikler sunar ve zaten aktif.

2

Response Cache'i Aktif Et

En buyuk performans kazanci buradan gelecek. Guest sayfalar icin dramatik hizlanma.

3

Memcache Ayari Eklemeye Gerek Yok

Redis zaten ayni isi yapiyor ve daha iyi. Memcache eski teknoloji.