← Lessons

quiz vs the machine

Silver1080

Databases

Redis Core Data Structures

Redis is more than a key value store thanks to its rich built in types.

4 min read · intro · beat Silver to climb

More Than Strings

Redis keeps data in memory and exposes typed values, not just opaque blobs. Each key points to one of several data structures, and the available commands depend on the type. This lets you push logic into the store instead of round tripping data to the client.

The Main Types

  • Strings hold text, numbers, or binary up to a fixed size. They power counters with atomic increment.
  • Hashes map fields to values, ideal for storing an object like a user record under one key.
  • Lists are ordered and let you push or pop from either end, useful for simple queues.
  • Sets hold unique members and support union and intersection.
  • Sorted Sets attach a score to each member, giving you ranked leaderboards in log time.

Why It Matters

Choosing the right type keeps operations fast and memory tight. A leaderboard built on a sorted set ranks players without scanning, while a hash avoids serializing a whole object to update one field.

Key idea

Redis values are typed structures with their own commands, so picking the right type turns the store into a fast purpose built tool rather than a plain cache.

Check yourself

Answer to earn rating on the learn ladder.

1. Which Redis type is best for a ranked leaderboard?

2. Why store a user object in a hash rather than a string?