Sets and Hashes in Redis

Sets and Hashes in Redis

Sorted Sets are often used in order to index data that is stored inside Redis. For instance if you have many hashes representing users, you can use a sorted set with elements having the age of the user as the score and the ID of the user as the value.

The topic for today is sets and hashes in Redis. These are two of the most useful data types in Redis and they’re often neglected by developers. It’s important to understand the fundamental concepts behind them because choosing the right data types helps a lot when trying to scale your application.

In this tutorial, I’m using Redis-Py to showcase the functionalities. The concept behind it is the same whichever programming language you use. Redis-Py uses the same name for function call as the original comand, with some minor exceptions. You can find the full list of the supported programming languages at the following link.

Setup

Make sure that you have Redis installed on your local machine. The local machine must consist of Linux distributions with minimal configuration settings.

Compiling on your own

You can download and compile it on your machine with the following commands (version 6.0.8 at the time of writing):

wget http://download.redis.io/releases/redis-6.0.8.tar.gz
tar xzf redis-6.0.8.tar.gz
cd redis-6.0.8
make

You should see a src folder when it’s completed. Change the working directory to src folder.

programming database redis python devops

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Guide to Python Programming Language

Guide to Python Programming Language

Python Programming: A Beginner’s Guide

Python is an interpreted, high-level, powerful general-purpose programming language. You may ask, Python’s a snake right? and Why is this programming language named after it?

Python Hello World Program - Create & Run Your First Python Program in PyCharm

Python Hello World Program - Your first step towards Python world. Learn how to create the Hello World Python program in PyCharm.

Python Programming Tutorials For Beginners

Python Programming Tutorials For Beginners

Redis Transactions & Long-Running Lua Scripts

Redis Lua scripting is the popularly recommended approach for handling transactions. Learn the common Lua Scripts error and how to handle for sentinel systems. Redis offers two mechanisms for handling transactions – MULTI/EXEC based transactions and Lua scripts evaluation. Redis Lua scripting is the recommended approach and is fairly popular in usage.