Nosql: A Quick Introduction To Redis
Nosql: A Quick Introduction To Redis
● In memory
Where is it used?
● Twitter
● Github
● Craigslist
● Pinterest
● StackOverflow
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!
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!