Ufraan's Notes Digital garden & personal knowledge base
Last modified: Jun 28, 2026Home / 02_cs / Databases / Redis / Redis Strings.Md

cs

Strings are the simplest and most commonly used data type in Redis.

A string is simply a key mapped to a value. The value can contain text, numbers, JSON, or even binary data.

Example:

user:name → "Ufraan"

Strings are often used for:

Basic Commands

SET

Stores a value under a key.

SET name "ufraan"

GET

Retrieves the value of a key.

GET name

OUTPUT:
"ufraan"

INCR

Increments a numeric value.

SET visits 10  
INCR visits

Result:
11

This is commonly used for counters, analytics tracking, and rate limiting.

Expiration

Keys can automatically expire using TTL.

SET token "abc123" EX 60

This stores the key for 60 seconds before Redis deletes it automatically.


Related:

[[Redis]] [[Redis - Lists]] [[Redis - Sets]] [[Redis - Hashes]] [[Redis-sorted-sets]