0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · Pelajaran

Struktur Data Inti Redis

Pahami dan terapkan String, Hash, List, Set, dan Sorted Set untuk berbagai kebutuhan pemodelan data.

Struktur Data Inti Redis adalah pelajaran Redis Caching & Messaging (Pub/Sub, Streams) gratis di CoddyKit. Ini adalah pelajaran 3 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Redis Caching & Messaging (Pub/Sub, Streams), dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Redis Caching & Messaging (Pub/Sub, Streams) mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

Redis Data Types & Strings

Redis offers real data structures, not just plain keys. We start with Strings: a value up to 512 MB holding text, JSON, or binary — like a persistent variable.

Strings: Set & Get

Store and read a String with SET and GET. The code below sets a couple of keys and fetches them back.

SET mykey "Hello CoddyKit!"
GET mykey
SET user:1:name "Alice"
GET user:1:name

Hashes: Store Objects

Redis Hashes are like objects: many field-value pairs under one key. Perfect for modeling things like a user profile with several attributes.

Hashes: HSET & HGETALL

Use HSET to set fields in a hash, HGETALL to read them all, and HGET for a single field. The code below builds and reads a user hash.

HSET user:1 name "Alice" email "alice@example.com" age 30
HGETALL user:1
HGET user:1 name

Lists: Ordered Collections

Redis Lists are ordered string collections — push or pop from either end. Great for queues, stacks, and recent-activity feeds that keep insertion order.

Lists: LPUSH & LRANGE

LPUSH adds to the head, RPUSH to the tail, and LRANGE reads a range (0 -1 means everything). The code below pushes and lists items.

LPUSH mylist "task A" "task B"
RPUSH mylist "task C"
LRANGE mylist 0 -1
LPOP mylist
LRANGE mylist 0 -1

Sets: Unique Items

Redis Sets are unordered collections of unique strings — duplicates are silently ignored. Ideal for unique visitors, tags, or friendships.

Sets: SADD & SMEMBERS

SADD adds members (dupes ignored), SMEMBERS lists them all, and SISMEMBER checks membership. The code below demonstrates all three.

SADD unique_users "user:101" "user:102" "user:101"
SMEMBERS unique_users
SISMEMBER unique_users "user:102"

Sorted Sets: Ranked Data

Redis Sorted Sets pair each unique member with a score and keep them ordered by it — perfect for leaderboards, rankings, and priority queues.

Sorted Sets: ZADD & ZRANGE

ZADD adds scored members, ZRANGE reads a range (add WITHSCORES to see scores), and ZSCORE gets one member's score. See the code below.

ZADD leaderboard 100 "PlayerA" 150 "PlayerB" 75 "PlayerC"
ZRANGE leaderboard 0 -1 WITHSCORES
ZSCORE leaderboard "PlayerB"

Data Structure Challenge

Imagine you need to store a list of unique product tags for an item, and you don't care about their order. Which Redis data structure is best suited for this?

Recap: Structures Mastered

Recap: Redis data structures — Strings for basics, Hashes for objects, Lists for ordered queues, Sets for unique items, Sorted Sets for ranked data.

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Struktur Data Inti Redis” gratis?

Ya — teks lengkap “Struktur Data Inti Redis” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Redis Caching & Messaging (Pub/Sub, Streams), upgrade ke CoddyKit PRO. Kursus Redis Caching & Messaging (Pub/Sub, Streams) mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Struktur Data Inti Redis”?

Pahami dan terapkan String, Hash, List, Set, dan Sorted Set untuk berbagai kebutuhan pemodelan data. Kamu berlatih Redis Caching & Messaging (Pub/Sub, Streams) dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai Redis Caching & Messaging (Pub/Sub, Streams)?

Tidak diperlukan pengalaman sebelumnya. Redis Caching & Messaging (Pub/Sub, Streams) di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 3 dari 4.

Berapa lama pelajaran “Struktur Data Inti Redis” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran Redis Caching & Messaging (Pub/Sub, Streams) ini?

Ya. Setiap pelajaran Redis Caching & Messaging (Pub/Sub, Streams) menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Pengantar Redis
  2. Dasar-Dasar Redis CLI
  3. Struktur Data Inti Redis
  4. Kedaluwarsa Kunci dan TTL di Redis
← Kembali ke Redis Caching & Messaging (Pub/Sub, Streams)