0% found this document useful (0 votes)
61 views

Nosql: A Quick Introduction To Redis

This document provides an introduction to Redis, including: 1. Redis is an in-memory key-value store that also supports data structures like strings, lists, hashes, sets, and sorted sets. 2. It is used by many large companies and has client libraries for different programming languages. 3. Unlike SQL databases, there are no tables in Redis - keys must be named carefully to link related data. 4. The document outlines several example problems demonstrating Redis basics like inserting, deleting, filtering, counting, and aggregating data using its various data structures and commands.

Uploaded by

koded
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Nosql: A Quick Introduction To Redis

This document provides an introduction to Redis, including: 1. Redis is an in-memory key-value store that also supports data structures like strings, lists, hashes, sets, and sorted sets. 2. It is used by many large companies and has client libraries for different programming languages. 3. Unlike SQL databases, there are no tables in Redis - keys must be named carefully to link related data. 4. The document outlines several example problems demonstrating Redis basics like inserting, deleting, filtering, counting, and aggregating data using its various data structures and commands.

Uploaded by

koded
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

NoSQL

A Quick Introduction to Redis


What is Redis?
● REmote DIctionary Server
● Key-value store (data-structure store?)

● In memory
Where is it used?
● Twitter
● Github
● Craigslist
● Pinterest
● StackOverflow

Lots of client libraries for different languages makes it


extremely accessible!
Redis Basics: Data Structures
● Keys and Values
● Values can be Data Structures
○ Strings
○ Lists
○ Hashes
○ Sets
○ Sorted Sets

This is an example
of storing a hash in
a key.
Redis Basics: Commands
● You need a different set of commands for each data
structure
○ Don’t worry -- the worksheet will guide you in using commands
○ You have a cheatsheet with all these commands

Use SET and GET Use HMSET and HGETALL or HGET for hashes
for a regular old
string
Redis Basics: Organization
● There are no tables in Redis databases
○ To link related info together, name your keys well!

● Solution: decide on the convention that all my “tuples”


will be stored in keys of the form user:<userID>.
○ Again, don’t worry too much -- just know that organization in Redis is
very different from SQL
Redis Basics
1. Key-value store, but values can be data
structures
2. Different sets of commands allow you to
set and get info from different data
structures
3. There are no tables -- organize your
database by naming keys well
Activity Overview
● Installing Redis & Getting Activity Data
● Three Problems
○ Walk through example
○ Try on your own
○ Share answers
■ (you will get candy)
● Discuss what Redis does well and what it
sucks at
○ (you will get candy here also)
Activity Time!
Installing Redis & Loading Data
(or finding someone who has it already)
5 minutes
Problem 1: Inserting and Deleting
Problem 1
Question 1)
HSET users johnsmith 11

Question 2)
DEL user:8
HDEL users bob

Question 3)
This doesn’t add a school field to all the other users.

Question 4)
HSET user:3 warning “this is a warning”
HSET user:5 warning “this is a warning”
HSET user:10 warning “this is a warning”
Problem 2: Filtering and Counting
Problem 2
Question 5)
cities:seattle:users
cities:tokyo:users
cities:chicago:users
cities:stanford:users
cities:boston:users

Question 6)
SADD cities:seattle:users 1
SADD cities:seattle:users 3
… and so on
Problem 2
Question 7)
Seattle: 2
Boston: 1
Tokyo: 1

Question 8)
● Ease of creating/maintaining
● Performance when modifying data

Question 9)
A Sorted Set! It has some nice functionality for dealing with numeric data.
Problem 3: Aggregation
Problem 3
Question 10)
ZADD users:ages 99 joy
ZADD users:ages 29 jill
… and so on

Question 11)
Problem 3
Question 12)
Kirito

Question 13)
Joy

Question 14)
Jill (but this isn’t quite right)
Discuss
● What actions were hard to do in Redis? What
actions were easy?
● What are the strengths and limitations of
Redis’s design compared to SQL?
What you should know
● Basic understanding of NoSQL
● Preliminary skills in using and designing a
Redis database
● An understanding of the pros and cons of
different design choices for database systems
The End!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy