{"id":34440,"date":"2025-11-16T17:41:35","date_gmt":"2025-11-16T14:41:35","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=34440"},"modified":"2025-11-16T17:41:35","modified_gmt":"2025-11-16T14:41:35","slug":"rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/","title":{"rendered":"Redis&#8217;te Sorted Set&#8217;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber"},"content":{"rendered":"<p><body><\/p>\n<h2>Redis&#8217;te Sorted Set&#8217;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber<\/h2>\n<p>Redis, y\u00fcksek performansl\u0131 ve esnek bir anahtar-de\u011fer veri deposudur ve \u00e7e\u015fitli veri yap\u0131lar\u0131n\u0131 destekler. Bu veri yap\u0131lar\u0131ndan biri olan Sorted Set&#8217;ler (S\u0131ral\u0131 K\u00fcmeler), geli\u015ftiricilere benzersiz elemanlar\u0131 bir puan (score) ile ili\u015fkilendirerek s\u0131ral\u0131 bir \u015fekilde depolama ve sorgulama imkan\u0131 sunar. Bu rehberde, Redis Sorted Set&#8217;lerin ne oldu\u011funu, temel ve geli\u015fmi\u015f komutlar\u0131n\u0131, pratik kullan\u0131m senaryolar\u0131n\u0131 ve performans ipu\u00e7lar\u0131n\u0131 detayl\u0131 bir \u015fekilde inceleyece\u011fiz.<\/p>\n<h3>Sorted Set Nedir ve Neden \u00d6nemlidir?<\/h3>\n<p>Sorted Set, her eleman\u0131n (member) benzersiz oldu\u011fu, ancak her eleman\u0131n bir kayan noktal\u0131 say\u0131 olan bir puanla (score) ili\u015fkilendirildi\u011fi bir veri yap\u0131s\u0131d\u0131r. Bu puanlar sayesinde, Sorted Set&#8217;teki elemanlar her zaman puanlar\u0131na g\u00f6re s\u0131ral\u0131 tutulur. E\u011fer iki eleman\u0131n puan\u0131 ayn\u0131ysa, Redis bu elemanlar\u0131 s\u00f6zl\u00fckbilimsel (lexicographical) olarak, yani \u00fcye string de\u011ferlerine g\u00f6re s\u0131ralar.<\/p>\n<p><strong>\u00d6nemli \u00d6zellikler:<\/strong><br \/>\n*   <strong>Benzersiz \u00dcyeler:<\/strong> Bir Sorted Set i\u00e7inde ayn\u0131 \u00fcye iki kez bulunamaz. E\u011fer ayn\u0131 \u00fcye farkl\u0131 bir puanla eklenirse, eski puan g\u00fcncellenir.<br \/>\n*   <strong>S\u0131ral\u0131 Depolama:<\/strong> Elemanlar her zaman puanlar\u0131na g\u00f6re k\u00fc\u00e7\u00fckten b\u00fcy\u00fc\u011fe do\u011fru s\u0131ral\u0131d\u0131r.<br \/>\n*   <strong>H\u0131zl\u0131 Eri\u015fim:<\/strong> Puan aral\u0131klar\u0131na g\u00f6re veya s\u0131ralar\u0131na g\u00f6re eleman \u00e7ekmek olduk\u00e7a h\u0131zl\u0131d\u0131r (O(log N) veya O(log N + M) karma\u015f\u0131kl\u0131kta).<\/p>\n<p><strong>Kullan\u0131m Alanlar\u0131:<\/strong><br \/>\n*   <strong>Lider Tablolar\u0131:<\/strong> Oyunlarda veya uygulamalarda en y\u00fcksek skora sahip kullan\u0131c\u0131lar\u0131 listelemek.<br \/>\n*   <strong>Ger\u00e7ek Zamanl\u0131 S\u0131ralamalar:<\/strong> Pop\u00fcler i\u00e7erikleri, en son yorumlar\u0131 veya trend olan konular\u0131 puanlar\u0131na g\u00f6re s\u0131ralamak.<br \/>\n*   <strong>Zaman Serileri Verileri:<\/strong> Skor olarak Unix timestamp kullanarak belirli bir zaman aral\u0131\u011f\u0131ndaki olaylar\u0131 veya verileri sorgulamak.<br \/>\n*   <strong>\u00d6ncelik Kuyruklar\u0131:<\/strong> D\u00fc\u015f\u00fck puan\u0131n y\u00fcksek \u00f6ncelik anlam\u0131na geldi\u011fi bir yap\u0131da, i\u015flenecek g\u00f6revleri \u00f6nceli\u011fe g\u00f6re s\u0131ralamak.<br \/>\n*   <strong>Co\u011frafi \u0130ndeksleme:<\/strong> Redis&#8217;in GEO komutlar\u0131, asl\u0131nda Sorted Set&#8217;lerin \u00f6zel bir uygulamas\u0131n\u0131 kullanarak co\u011frafi konumlar\u0131 indeksler ve belirli bir yar\u0131\u00e7aptaki konumlar\u0131 bulur.<\/p>\n<p>Sorted Set&#8217;ler, bu t\u00fcr senaryolarda verimli ve h\u0131zl\u0131 \u00e7\u00f6z\u00fcmler sunarak modern uygulamalar\u0131n bel kemi\u011fini olu\u015fturur.<\/p>\n<h3>Sorted Set Temel Komutlar\u0131 ve Kullan\u0131m\u0131<\/h3>\n<p>Redis Sorted Set&#8217;leri y\u00f6netmek i\u00e7in bir dizi g\u00fc\u00e7l\u00fc komut sunar. \u0130\u015fte en s\u0131k kullan\u0131lanlar:<\/p>\n<h4>Eleman Ekleme ve G\u00fcncelleme: ZADD<\/h4>\n<p><code>ZADD<\/code> komutu, bir veya daha fazla eleman\u0131 (member) belirtilen bir puanla (score) Sorted Set&#8217;e eklemek i\u00e7in kullan\u0131l\u0131r. E\u011fer eleman zaten varsa, puan\u0131 g\u00fcncellenir.<\/p>\n<pre><code class=\"language-redis\">ZADD myleaderboard 100 \"user:ali\" 200 \"user:veli\" 150 \"user:ayse\"<\/code><\/pre>\n<p>Bu komut, <code>myleaderboard<\/code> adl\u0131 Sorted Set&#8217;e Ali, Veli ve Ay\u015fe&#8217;yi puanlar\u0131yla birlikte ekler.<\/p>\n<h4>Elemanlar\u0131 S\u0131ral\u0131 \u00c7ekme: ZRANGE ve ZREVRANGE<\/h4>\n<p><code>ZRANGE<\/code> komutu, Sorted Set&#8217;teki elemanlar\u0131 artan puan s\u0131ras\u0131na g\u00f6re belirli bir aral\u0131kta (indeks) \u00e7ekmek i\u00e7in kullan\u0131l\u0131r. <code>ZREVRANGE<\/code> ise azalan puan s\u0131ras\u0131na g\u00f6re \u00e7eker. <code>WITHSCORES<\/code> parametresi, elemanlar\u0131n puanlar\u0131n\u0131 da d\u00f6nd\u00fcr\u00fcr.<\/p>\n<pre><code class=\"language-redis\"># En d\u00fc\u015f\u00fck puanl\u0131dan en y\u00fcksek puanl\u0131ya t\u00fcm elemanlar\u0131 \u00e7ek\nZRANGE myleaderboard 0 -1 WITHSCORES\n<h2>\u00c7\u0131kt\u0131: \"user:ali\" \"100\" \"user:ayse\" \"150\" \"user:veli\" \"200\"<\/h2>\n\n<h2>En y\u00fcksek puanl\u0131dan en d\u00fc\u015f\u00fck puanl\u0131ya ilk 2 eleman\u0131 \u00e7ek (top 2)<\/h2>\nZREVRANGE myleaderboard 0 1 WITHSCORES\n<h2>\u00c7\u0131kt\u0131: \"user:veli\" \"200\" \"user:ayse\" \"150\"<\/code><\/pre>\n<\/h2>\n<h4>Puan Aral\u0131\u011f\u0131na G\u00f6re Eleman \u00c7ekme: ZRANGEBYSCORE<\/h4>\n<p><code>ZRANGEBYSCORE<\/code> komutu, belirli bir puan aral\u0131\u011f\u0131ndaki elemanlar\u0131 \u00e7ekmek i\u00e7in kullan\u0131l\u0131r. <code>( <\/code> ve <code>[<\/code> i\u015faretleri, aral\u0131\u011f\u0131n dahil olup olmad\u0131\u011f\u0131n\u0131 belirtir. <code>(<\/code> hari\u00e7, <code>[<\/code> dahil anlam\u0131na gelir. <code>+inf<\/code> ve <code>-inf<\/code> sonsuzluk de\u011ferlerini ifade eder.<\/p>\n<pre><code class=\"language-redis\"># Puan\u0131 100 ile 170 (dahil) aras\u0131ndaki elemanlar\u0131 \u00e7ek\nZRANGEBYSCORE myleaderboard 100 170 WITHSCORES\n<h2>\u00c7\u0131kt\u0131: \"user:ali\" \"100\" \"user:ayse\" \"150\"<\/h2>\n\n<h2>Puan\u0131 150'den b\u00fcy\u00fck (hari\u00e7) olan elemanlar\u0131 \u00e7ek<\/h2>\nZRANGEBYSCORE myleaderboard (150 +inf WITHSCORES\n<h2>\u00c7\u0131kt\u0131: \"user:veli\" \"200\"<\/h2>\n\n<h2>Sonu\u00e7lar\u0131 s\u0131n\u0131rland\u0131rmak (sayfalama)<\/h2>\nZRANGEBYSCORE myleaderboard 0 200 WITHSCORES LIMIT 0 1\n<h2>\u00c7\u0131kt\u0131: \"user:ali\" \"100\"<\/code><\/pre>\n<\/h2>\n<h4>Eleman Silme: ZREM<\/h4>\n<p><code>ZREM<\/code> komutu, bir veya daha fazla eleman\u0131 Sorted Set&#8217;ten silmek i\u00e7in kullan\u0131l\u0131r.<\/p>\n<pre><code class=\"language-redis\">ZREM myleaderboard \"user:ali\"\n<h2>myleaderboard'dan user:ali silinir<\/code><\/pre>\n<\/h2>\n<h4>Eleman\u0131n Puan\u0131n\u0131 Alma: ZSCORE<\/h4>\n<p><code>ZSCORE<\/code> komutu, belirli bir eleman\u0131n mevcut puan\u0131n\u0131 d\u00f6nd\u00fcr\u00fcr.<\/p>\n<pre><code class=\"language-redis\">ZSCORE myleaderboard \"user:veli\"\n<h2>\u00c7\u0131kt\u0131: \"200\"<\/code><\/pre>\n<\/h2>\n<h4>Eleman Say\u0131s\u0131 ve Puan Aral\u0131\u011f\u0131ndaki Say\u0131: ZCARD ve ZCOUNT<\/h4>\n<p><code>ZCARD<\/code> Sorted Set&#8217;teki toplam eleman say\u0131s\u0131n\u0131 d\u00f6nd\u00fcr\u00fcrken, <code>ZCOUNT<\/code> belirli bir puan aral\u0131\u011f\u0131ndaki eleman say\u0131s\u0131n\u0131 d\u00f6nd\u00fcr\u00fcr.<\/p>\n<pre><code class=\"language-redis\">ZCARD myleaderboard\n<h2>\u00c7\u0131kt\u0131: (integer) 2 (Ali'yi sildikten sonra)<\/h2>\n\nZCOUNT myleaderboard 100 150\n<h2>\u00c7\u0131kt\u0131: (integer) 1 (Ay\u015fe'nin puan\u0131 150)<\/code><\/pre>\n<\/h2>\n<h4>Eleman\u0131n Puan\u0131n\u0131 Artt\u0131rma\/Azaltma: ZINCRBY<\/h4>\n<p><code>ZINCRBY<\/code> komutu, bir eleman\u0131n puan\u0131n\u0131 belirtilen bir de\u011fer kadar art\u0131r\u0131r veya azalt\u0131r (negatif de\u011fer ile).<\/p>\n<pre><code class=\"language-redis\">ZINCRBY myleaderboard 50 \"user:veli\"\n<h2>user:veli'nin puan\u0131 200'den 250'ye \u00e7\u0131kar.<\/h2>\n\nZSCORE myleaderboard \"user:veli\"\n<h2>\u00c7\u0131kt\u0131: \"250\"<\/code><\/pre>\n<\/h2>\n<h3>Geli\u015fmi\u015f Sorted Set Operasyonlar\u0131 ve Senaryolar\u0131<\/h3>\n<p>Sorted Set&#8217;ler, temel komutlar\u0131n\u0131n \u00f6tesinde, daha karma\u015f\u0131k veri y\u00f6netimi senaryolar\u0131 i\u00e7in de g\u00fc\u00e7l\u00fc ara\u00e7lar sunar.<\/p>\n<h4>Lider Tablolar\u0131 Olu\u015fturma<\/h4>\n<p>Lider tablolar\u0131, Sorted Set&#8217;lerin en yayg\u0131n kullan\u0131m alanlar\u0131ndan biridir. <code>ZADD<\/code> ile kullan\u0131c\u0131 skorlar\u0131n\u0131 ekler, <code>ZREVRANGE<\/code> ile en y\u00fcksek skorlular\u0131 listeler ve <code>ZRANK<\/code> (veya <code>ZREVRANK<\/code>) ile bir kullan\u0131c\u0131n\u0131n s\u0131ras\u0131n\u0131 bulabilirsiniz.<\/p>\n<pre><code class=\"language-redis\"># Yeni skorlar ekle\/g\u00fcncelle\nZADD game:leaderboard 300 \"player:bob\" 450 \"player:alice\" 280 \"player:charlie\"\n\n<h2>En iyi 5 oyuncuyu puanlar\u0131yla birlikte listele<\/h2>\nZREVRANGE game:leaderboard 0 4 WITHSCORES\n\n<h2>Alice'in s\u0131ras\u0131n\u0131 bul (en y\u00fcksekten en d\u00fc\u015f\u00fc\u011fe)<\/h2>\nZREVRANK game:leaderboard \"player:alice\"\n<h2>\u00c7\u0131kt\u0131: (integer) 0 (0 tabanl\u0131 indeks, yani 1. s\u0131rada)<\/code><\/pre>\n<\/h2>\n<h4>Zaman Serileri Verileriyle \u00c7al\u0131\u015fma<\/h4>\n<p>Skor olarak Unix timestamp (saniye cinsinden zaman damgas\u0131) kullanarak, olaylar\u0131 kronolojik s\u0131raya g\u00f6re depolayabilir ve belirli zaman aral\u0131klar\u0131ndaki verileri sorgulayabilirsiniz.<\/p>\n<pre><code class=\"language-redis\"># Log kay\u0131tlar\u0131 ekle (timestamp, log_id)\nZADD logs:server1 1678886400 \"log:001\" 1678886460 \"log:002\" 1678886520 \"log:003\"\n<h2>(1678886400 = 2023-03-15 00:00:00 UTC)<\/h2>\n\n<h2>Son bir saatteki (3600 saniye) loglar\u0131 \u00e7ek<\/h2>\n<h2>Mevcut zaman\u0131 al\u0131p 3600 \u00e7\u0131kararak aral\u0131k belirlenir<\/h2>\nZRANGEBYSCORE logs:server1 (1678886460-3600) 1678886460 WITHSCORES<\/code><\/pre>\n<h4>\u00d6ncelik Kuyruklar\u0131 Y\u00f6netimi<\/h4>\n<p>D\u00fc\u015f\u00fck puan\u0131n daha y\u00fcksek \u00f6ncelik anlam\u0131na geldi\u011fi bir senaryoda, <code>ZRANGE 0 0<\/code> komutu ile her zaman en y\u00fcksek \u00f6ncelikli (en d\u00fc\u015f\u00fck puanl\u0131) eleman\u0131 alabilir ve i\u015fledikten sonra <code>ZREM<\/code> ile silebilirsiniz.<\/p>\n<pre><code class=\"language-redis\"># G\u00f6revleri \u00f6nceliklerine g\u00f6re ekle (d\u00fc\u015f\u00fck puan = y\u00fcksek \u00f6ncelik)\nZADD task:queue 10 \"task:urgent\" 50 \"task:normal\" 100 \"task:low\"\n\n<h2>\u0130\u015flenecek en \u00f6ncelikli g\u00f6revi al<\/h2>\nZRANGE task:queue 0 0 WITHSCORES\n<h2>\u00c7\u0131kt\u0131: \"task:urgent\" \"10\"<\/h2>\n\n<h2>G\u00f6rev i\u015flendikten sonra kuyruktan sil<\/h2>\nZREM task:queue \"task:urgent\"<\/code><\/pre>\n<h4>Birden Fazla Sorted Set&#8217;i Birle\u015ftirme veya Kesi\u015fimini Alma: ZUNIONSTORE ve ZINTERSTORE<\/h4>\n<p>Bu komutlar, birden fazla Sorted Set&#8217;i birle\u015ftirerek (UNION) veya kesi\u015fimini alarak (INTERSECTION) sonu\u00e7lar\u0131 yeni bir Sorted Set&#8217;e kaydeder. <code>WEIGHTS<\/code> parametresi ile her bir setin puanlar\u0131na a\u011f\u0131rl\u0131k verebilir ve <code>AGGREGATE<\/code> fonksiyonu (SUM, MIN, MAX) ile \u00e7ak\u0131\u015fan elemanlar\u0131n puanlar\u0131n\u0131n nas\u0131l birle\u015ftirilece\u011fini belirleyebilirsiniz.<\/p>\n<pre><code class=\"language-redis\"># Pop\u00fcler \u00fcr\u00fcnler\nZADD popular:products 100 \"product:A\" 80 \"product:B\" 120 \"product:C\"\n\n<h2>Yeni \u00fcr\u00fcnler (puan = eklenme zaman\u0131)<\/h2>\nZADD new:products 1678886400 \"product:A\" 1678886500 \"product:D\" 1678886600 \"product:C\"\n\n<h2>Hem pop\u00fcler hem de yeni olan \u00fcr\u00fcnleri birle\u015ftir (puanlar\u0131 topla)<\/h2>\n<h2>A\u011f\u0131rl\u0131klar ile pop\u00fclerli\u011fi ve yenili\u011fi birle\u015ftirerek yeni bir s\u0131ralama olu\u015ftur<\/h2>\nZUNIONSTORE combined:products 2 popular:products new:products WEIGHTS 1 1 AGGREGATE SUM\n\n<h2>combined:products i\u00e7eri\u011fi<\/h2>\nZRANGE combined:products 0 -1 WITHSCORES\n<h2>product:D (1678886500) - sadece new:products'ta<\/h2>\n<h2>product:B (80) - sadece popular:products'ta<\/h2>\n<h2>product:A (100+1678886400)<\/h2>\n<h2>product:C (120+1678886600)<\/h2>\n<h2>Bu \u00f6rnekte timestamp ile skorlar\u0131 toplamak mant\u0131kl\u0131 olmayabilir,<\/h2>\n<h2>ancak farkl\u0131 a\u011f\u0131rl\u0131klarla pop\u00fclerlik ve yenilik skorlar\u0131n\u0131 birle\u015ftirmek i\u00e7in idealdir.<\/h2>\n<h2>\u00d6rne\u011fin, pop\u00fclerlik ve yenilik skorlar\u0131 0-100 aras\u0131nda normalize edilmi\u015fse:<\/h2>\n<h2>ZUNIONSTORE combined:products 2 popular:products new:products WEIGHTS 0.7 0.3 AGGREGATE SUM<\/code><\/pre>\n<\/h2>\n<h3>Sorted Set Performans\u0131 ve Optimizasyon \u0130pu\u00e7lar\u0131<\/h3>\n<p>Redis Sorted Set&#8217;ler, b\u00fcy\u00fck veri setleriyle bile olduk\u00e7a iyi performans g\u00f6sterir. Ancak, daha verimli bir kullan\u0131m i\u00e7in baz\u0131 optimizasyon ipu\u00e7lar\u0131 ve performans detaylar\u0131n\u0131 bilmek faydal\u0131d\u0131r.<\/p>\n<h4>Bellek Kullan\u0131m\u0131<\/h4>\n<p>Redis, Sorted Set&#8217;leri dahili olarak iki farkl\u0131 veri yap\u0131s\u0131yla temsil edebilir:<br \/>\n*   <strong>Ziplist:<\/strong> K\u00fc\u00e7\u00fck Sorted Set&#8217;ler i\u00e7in kullan\u0131l\u0131r. Elemanlar ve puanlar bellekte ard\u0131\u015f\u0131k olarak tutulur, bu da bellek verimlili\u011fi ve CPU cache dostu olmas\u0131n\u0131 sa\u011flar.<br \/>\n*   <strong>Skip List:<\/strong> Daha b\u00fcy\u00fck Sorted Set&#8217;ler i\u00e7in kullan\u0131l\u0131r. Her eleman\u0131n puan\u0131na g\u00f6re h\u0131zl\u0131 arama, ekleme ve silme i\u015flemlerini O(log N) karma\u015f\u0131kl\u0131kta ger\u00e7ekle\u015ftiren bir veri yap\u0131s\u0131d\u0131r.<\/p>\n<p>Redis, belirli e\u015fik de\u011ferlerinin (varsay\u0131lan olarak <code>zset-max-ziplist-entries<\/code> ve <code>zset-max-ziplist-value<\/code>) \u00fczerine \u00e7\u0131k\u0131ld\u0131\u011f\u0131nda Ziplist&#8217;ten Skip List&#8217;e otomatik olarak ge\u00e7i\u015f yapar. Bu e\u015fikleri Redis yap\u0131land\u0131rma dosyas\u0131nda ayarlayarak bellek ve performans aras\u0131nda denge kurabilirsiniz.<\/p>\n<h4>Komut Karma\u015f\u0131kl\u0131klar\u0131<\/h4>\n<p>\u00c7o\u011fu Sorted Set komutu, ekleme, silme ve tekil eleman sorgular\u0131 i\u00e7in O(log N) zaman karma\u015f\u0131kl\u0131\u011f\u0131na sahiptir. Aral\u0131k sorgular\u0131 (<code>ZRANGE<\/code>, <code>ZRANGEBYSCORE<\/code>) ise O(log N + M) karma\u015f\u0131kl\u0131\u011f\u0131ndad\u0131r, burada N Sorted Set&#8217;in boyutu, M ise d\u00f6nen eleman say\u0131s\u0131d\u0131r. Bu, Sorted Set&#8217;lerin \u00e7ok b\u00fcy\u00fck boyutlara ula\u015fsa bile performans\u0131n logaritmik olarak artaca\u011f\u0131 anlam\u0131na gelir.<\/p>\n<h4>Pipeline Kullan\u0131m\u0131<\/h4>\n<p>Birden fazla Redis komutunu tek bir a\u011f gidi\u015f-d\u00f6n\u00fc\u015f\u00fcnde g\u00f6ndermek (pipelining), a\u011f gecikmesini azaltarak performans\u0131 \u00f6nemli \u00f6l\u00e7\u00fcde art\u0131rabilir. \u00d6zellikle \u00e7ok say\u0131da <code>ZADD<\/code> veya <code>ZREM<\/code> i\u015flemi yap\u0131yorsan\u0131z, pipeline kullanmak verimlili\u011fi art\u0131racakt\u0131r.<\/p>\n<h4>Member Boyutlar\u0131<\/h4>\n<p>Sorted Set \u00fcyeleri string oldu\u011fundan, \u00fcye stringlerinin uzunlu\u011fu bellek kullan\u0131m\u0131n\u0131 do\u011frudan etkiler. \u00c7ok uzun \u00fcye stringleri kullanmaktan ka\u00e7\u0131nmak veya bunlar\u0131 k\u0131saltmak (\u00f6rne\u011fin, UUID yerine daha k\u0131sa hash&#8217;ler kullanmak), bellek ayak izini azaltabilir.<\/p>\n<h4>Veri Ya\u015fam S\u00fcresi (TTL) Y\u00f6netimi<\/h4>\n<p>Sorted Set&#8217;in tamam\u0131na bir TTL (Time-To-Live) atayabilirsiniz (<code>EXPIRE<\/code> komutu ile), ancak Sorted Set i\u00e7indeki tek tek elemanlara TTL atayamazs\u0131n\u0131z. E\u011fer belirli elemanlar\u0131n belirli bir s\u00fcre sonra otomatik olarak silinmesini istiyorsan\u0131z, bunu uygulama taraf\u0131nda y\u00f6netmeniz veya elemanlar\u0131n skorunu zaman damgas\u0131 olarak kullanarak <code>ZREMRANGEBYSCORE<\/code> veya <code>ZREMRANGEBYRANK<\/code> ile eski elemanlar\u0131 periyodik olarak temizlemeniz gerekir.<\/p>\n<h3>Sonu\u00e7 ve S\u0131k\u00e7a Sorulan Sorular (SSS)<\/h3>\n<p>Redis Sorted Set&#8217;ler, puan tabanl\u0131 s\u0131ralama gerektiren bir\u00e7ok uygulama senaryosu i\u00e7in son derece g\u00fc\u00e7l\u00fc ve esnek bir veri yap\u0131s\u0131d\u0131r. Lider tablolar\u0131ndan zaman serisi verilerine, \u00f6ncelik kuyruklar\u0131ndan co\u011frafi indekslemeye kadar geni\u015f bir kullan\u0131m yelpazesi sunar. Do\u011fru komutlar\u0131 ve optimizasyon tekniklerini kullanarak, uygulamalar\u0131n\u0131zda y\u00fcksek performansl\u0131 ve \u00f6l\u00e7eklenebilir \u00e7\u00f6z\u00fcmler olu\u015fturabilirsiniz.<\/p>\n<h4>S\u0131k\u00e7a Sorulan Sorular (SSS)<\/h4>\n<p><strong>1. Bir Sorted Set&#8217;teki elemanlar benzersiz midir?<\/strong><br \/>\nEvet, bir Sorted Set&#8217;teki t\u00fcm \u00fcyeler (members) benzersizdir. E\u011fer ayn\u0131 \u00fcye farkl\u0131 bir puanla <code>ZADD<\/code> edilirse, \u00fcyenin puan\u0131 g\u00fcncellenir.<\/p>\n<p><strong>2. Bir eleman\u0131n puan\u0131n\u0131 de\u011fi\u015ftirmek ne kadar s\u00fcrer?<\/strong><br \/>\nBir eleman\u0131n puan\u0131n\u0131 de\u011fi\u015ftirmek veya yeni bir eleman eklemek O(log N) zaman karma\u015f\u0131kl\u0131\u011f\u0131na sahiptir, burada N Sorted Set&#8217;teki eleman say\u0131s\u0131d\u0131r. Bu, \u00e7ok b\u00fcy\u00fck setlerde bile olduk\u00e7a h\u0131zl\u0131d\u0131r.<\/p>\n<p><strong>3. Sorted Set&#8217;ler ne zaman kullan\u0131lmamal\u0131d\u0131r?<\/strong><br \/>\nE\u011fer sadece benzersiz elemanlara ihtiyac\u0131n\u0131z varsa ve s\u0131ralama \u00f6nemli de\u011filse, Redis Set&#8217;ler daha uygun olabilir. E\u011fer s\u0131ral\u0131 bir liste istiyorsan\u0131z ancak her eleman\u0131n \u00f6zel bir puan\u0131 yoksa ve indeks tabanl\u0131 eri\u015fim yeterliyse, Redis List&#8217;ler daha iyi bir se\u00e7im olabilir. Sorted Set&#8217;ler, \u00f6zellikle bir puanlama veya \u00f6nceliklendirme mekanizmas\u0131na ihtiya\u00e7 duyuldu\u011funda parlar.<\/p>\n<p><strong>4. Ayn\u0131 puana sahip elemanlar nas\u0131l s\u0131ralan\u0131r?<\/strong><br \/>\nE\u011fer iki veya daha fazla eleman\u0131n puan\u0131 ayn\u0131ysa, Redis bu elemanlar\u0131 s\u00f6zl\u00fckbilimsel (lexicographical) olarak, yani \u00fcye string de\u011ferlerine g\u00f6re artan s\u0131rada s\u0131ralar. \u00d6rne\u011fin, &#8220;apple&#8221; ve &#8220;banana&#8221; ayn\u0131 puana sahipse, &#8220;apple&#8221; \u00f6nce gelir.<\/p>\n<p><strong>5. Sorted Set&#8217;in boyutu artt\u0131k\u00e7a performans nas\u0131l etkilenir?<\/strong><br \/>\nSorted Set&#8217;lerin \u00e7o\u011fu i\u015flemi (ekleme, silme, tekil sorgu) O(log N) karma\u015f\u0131kl\u0131\u011fa sahiptir. Bu, setin boyutu N artt\u0131k\u00e7a performans\u0131n logaritmik olarak artaca\u011f\u0131 anlam\u0131na gelir. Yani, set \u00e7ok b\u00fcy\u00fcse bile performans d\u00fc\u015f\u00fc\u015f\u00fc do\u011frusal de\u011fil, \u00e7ok daha yava\u015ft\u0131r. Bu da Sorted Set&#8217;leri milyonlarca elemanla bile kullan\u0131labilir k\u0131lar.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Redis&#8217;te Sorted Set&#8217;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber\nRedis, y\u00fcksek performansl\u0131 ve esnek bir anahtar-de\u011fer veri deposudur ve \u00e7e\u015fitli veri","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[1404],"tags":[],"class_list":{"0":"post-34440","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-redis","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Redis&#039;te Sorted Set&#039;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Redis&#039;te Sorted Set&#039;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber\" \/>\n<meta property=\"og:description\" content=\"Redis&#039;te Sorted Set&#039;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber Redis, y\u00fcksek performansl\u0131 ve esnek bir anahtar-de\u011fer veri deposudur ve \u00e7e\u015fitli veri\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-16T14:41:35+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Redis&#8217;te Sorted Set&#8217;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber\",\"datePublished\":\"2025-11-16T14:41:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/\"},\"wordCount\":1593,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"Redis\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/\",\"name\":\"Redis'te Sorted Set'leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-11-16T14:41:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Redis&#8217;te Sorted Set&#8217;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Redis'te Sorted Set'leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/","og_locale":"tr_TR","og_type":"article","og_title":"Redis'te Sorted Set'leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber","og_description":"Redis'te Sorted Set'leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber Redis, y\u00fcksek performansl\u0131 ve esnek bir anahtar-de\u011fer veri deposudur ve \u00e7e\u015fitli veri","og_url":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-11-16T14:41:35+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"10 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Redis&#8217;te Sorted Set&#8217;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber","datePublished":"2025-11-16T14:41:35+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/"},"wordCount":1593,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["Redis"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/","url":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/","name":"Redis'te Sorted Set'leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-11-16T14:41:35+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/rediste-sorted-setleri-yonetmek-kapsamli-bir-rehber\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Redis&#8217;te Sorted Set&#8217;leri Y\u00f6netmek: Kapsaml\u0131 Bir Rehber"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/34440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=34440"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/34440\/revisions"}],"predecessor-version":[{"id":34441,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/34440\/revisions\/34441"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=34440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=34440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=34440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}