Databases 6 min read

Redis Common Data Types and Commands Overview

This article introduces Redis's primary data structures—String, Hash, List, and Set—explaining their purpose, key commands, and practical usage examples, including batch operations, numeric adjustments, field management, list manipulation, and set operations, to help developers effectively work with the in‑memory database.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Redis Common Data Types and Commands Overview

Redis provides several common data types: String, Hash, List, and Set, each with specific commands for manipulation.

String type is the basic key‑value pair. Commands include set key value to assign, get key to retrieve, mset key value ... keyN valueN and mget key ... keyN for batch operations, getset key value to get and set atomically, del key ... to delete, incr key / decr key and their by variants for numeric adjustments, append key value , and strlen key . Example session shows setting a key, retrieving it, and performing numeric increments.

Hash type stores a map of fields to values, similar to a Java HashMap . Commands such as hset key field value , hmset key field value ... fieldN valueN , hget key field , hmget key field ... , hgetall key , hdel key field ... , hexists key field , hkeys key , hvals key , and hlen key manage fields. Example demonstrates creating a user hash, adding fields, and retrieving them.

List type implements a linked‑list of strings. Commands include lpush key value ... , rpush key value ... , lrange key startIndex endIndex , llen key , lindex key index , lset key index value , lpop key , rpop key , ltrim key startIndex endIndex , linsert key after|before index value , and rpoplpush key otherListKey . The article shows pushing elements, listing them, popping from both ends, and inserting at specific positions.

Set type is an unordered collection of unique strings backed by a hash table. Commands include sadd key value ... , srem key value ... , smembers key , sismember key value , sdiff key1 key2 , sinter key1 key2 , sunion key1 key2 , and scard key . Sample commands illustrate adding members, checking existence, and performing set operations such as difference.

The guide also provides links to related articles on Redis deployment, configuration, and community resources.

DatabaseRedisData TypescommandsKey-Value Store
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.