Redis: A Key-Value NoSQL Database Overview

 
Introduction to Redis
 
CS237 Presentation Group 5
Qirui  Yang
Mingyuan Yang
Jiannan Tan
 
01
 
Redis is a NoSQL database which follows the principle of
key-value store. The key-value store provides ability to store
some data called a value, inside a key. You can recieve this
data later only if you know the exact key used to store it.
 
Redis is a flexible, open-source (BSD licensed), in-memory
data structure store, used as database, cache, and message
broker. Redis is a NoSQL database so it facilitates users to
store huge amount of data without the limit of a Relational
database.
 
Redis supports various types of data structures like strings,
hashes, lists, sets, sorted sets, bitmaps, hyperloglogs and
geospatial indexes with radius queries.
 
what is Redis?
 
01
 
what is Redis?
 
Redis Architecture
 
There are two main processes in Redis architecture:
(1) Redis Client
(2) Redis Server
 
These client and server can be on same computer or two different
computers.
 
Redis allows us to store keys that map to any one of five different data
structure
 
types:
 
STRING, LIST, SET, HASH, and ZSETs.
 
0
2
 
Data Structure types
 
Strings
 
in
 
Redis
 
Command
 
used on STRING values
 
An example of a STRING, world, stored under a key, hello
 
In Redis, STRINGs are similar to strings that we
see in other languages or other key-value stores.
Generally, when I show diagrams that represent
keys and values, the diagrams have the key name
and the type of the value along the top of a box,
with the value inside the box.
 
 
0
2
 
Data Structure types
 
Lists
 
in
 
Redis
 
Command
 
used on LIST values
 
An example of a LIST with three items under the key, list-key
 
In key-value stores, Redis is unique in that it supports a
linked-list structure. LISTs in Redis store an ordered
sequence of strings, and like STRINGs.
 
0
2
 
Data Structure types
 
Sets
 
in
 
Redis
 
An example of a SET with three items under the key, set-key
 
In Redis, SETs are similar to LISTs in that they’re a sequence of
strings, but unlike LISTs, Redis SETs use a hash table to keep all
strings unique (though there are no associated values).
Because Redis SETs are unordered, we can’t push and pop items
from the ends like we did with LISTs. Instead, we add and
remove items by value with the SADD and SREM commands.
We can also find out whether an item is in the SET quickly
with SISMEMBER, or fetch the entire set
with SMEMBERS (this can be slow for large SETs, so be
careful).
 
Commands used on SET values
 
0
2
 
Data Structure types
 
Hashes
 
in
 
Redis
 
Command
 
used on HASH values
 
An example of a HASH with two keys/values under the key, hash-key
 
Redis HASHes store a mapping of keys to values.
The values that can be stored in HASHes are the
same as what can be stored as normal STRINGs:
strings themselves, or if a value can be interpreted
as a number, that value can be incremented or
decremented.
 
0
2
 
Data Structure types
 
Zsets
 
in
 
Redis
 
Command
 
used on ZSET values
 
An example of a ZSET with two members/scores under the key
,
 zset-key
 
Like Redis HASHes, ZSETs also hold a type of key and
value. The keys (called members) are unique, and the
values (called scores) are limited to floating-point
numbers. ZSETs have the unique property in Redis of being
able to be accessed by member (like a HASH), but items
can also be accessed by the sorted order and values of the
scores.
 
Data Structure types
 
0
2
 
1. put all the data in memory
 
The speed of disk I/O seriously affects redis
performance if data is not stored in memory
 
2.Single thread
 
If there is only one thread, processing requests in
memory can be quick without context switching
 
Redis is a Key-Value memory
database. All the data is stored in
memory in 
the
 form 
of key/value
 
0
3
 
Principle
 
Mu
ltiple
 
requests 
may produce
different operations concurrently, but
IO multiplexers listen to multiple
requests 
, queue 
the 
events, and the
event dispatcher takes one event from
the queue at a time and hands the event
over to the corresponding event
processor for processing
.
 
0
3
 
Principle
 
1. RDB
Redis will build a snapshot of database
 
2.AOF
Redis will store how we operate database
in AOF files
 
The data is in memory. Once 
server
 is
restarted, the data disappears. We need to
back it up to 
disk
 
Principle
 
0
3
 
1.Redis not only supports  key/value types of data, but also provides more data structures such as
list,set,zset,hash.
 
2.Redis support that the data in memory can be kept on disk and can be reloaded when rebooted.
 
3.Memcached is multithreading, resulting in performance losses;
Redis use single thread and fast speed
 
4.Redis can realize master-slave replication and data recovery
 
0
4
 
Compared with Memcached
 
Redis
 
use
 
cases
 
1. Session cache
One of the most apparent use cases for Redis is using it as a session cache. The advantage of using Redis over other
session stores, such as Memcached, is that Redis offers persistence. While maintaining a cache isn’t typically mission-
critical with regards to consistency, most users might be upset if all their cart sessions go away.
 
2. Full-page cache
Outside of your basic session tokens, Redis provides a straightforward Full-page cache (FPC) platform in which to
operate. Consistency factors here, too. Even across restarts of Redis instances, with disk persistence, your users don’t
see a decrease in speed for their page loads—a drastic change from something similar to PHP native FPC.
 
3
. Leaderboards and counting
Redis does a great job with increments and decrements because it’s in-memory. Sets and sorted sets also make our lives
easier when we do these kinds of operations. Redis just so happens to offer both of these data structures.
 
4
. Publish-Subscribe
Redis has a Publish-Subscribe (Pub/Sub) feature. The use cases for Pub/Sub are boundless. I’ve seen people use it for
social network connections, for triggering scripts based on Pub/Sub events, and even for a chat system built using Redis
Pub/Sub.
 
0
5
 
Thank you
Slide Note
Embed
Share

Redis is a flexible in-memory data structure store that acts as a database, cache, and message broker. It follows a key-value store principle, offering various data structures like strings, lists, sets, and more. Redis allows users to store a large amount of data without the limitations of relational databases. The architecture includes two main processes: Redis Client and Redis Server, which can be on the same or different computers. Different data types like strings, lists, and sets are explained along with their commands and functionalities in Redis.

  • Redis
  • NoSQL
  • Data Structures
  • Key-Value Store
  • Database

Uploaded on Sep 28, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Introduction to Redis CS237 Presentation Group 5 Qirui Yang Mingyuan Yang Jiannan Tan

  2. what is Redis? 01 Redis is a NoSQL database which follows the principle of key-value store. The key-value store provides ability to store some data called a value, inside a key. You can recieve this data later only if you know the exact key used to store it. Redis is a flexible, open-source (BSD licensed), in-memory data structure store, used as database, cache, and message broker. Redis is a NoSQL database so it facilitates users to store huge amount of data without the limit of a Relational database. Redis supports various types of data structures like strings, hashes, lists, sets, sorted sets, bitmaps, hyperloglogs and geospatial indexes with radius queries.

  3. 01 what is Redis? Redis Architecture There are two main processes in Redis architecture: (1) Redis Client (2) Redis Server These client and server can be on same computer or two different computers.

  4. 02 Data Structure types Redis allows us to store keys that map to any one of five different data structure types: STRING, LIST, SET, HASH, and ZSETs.

  5. 02 Data Structure types Strings in Redis In Redis, STRINGs are similar to strings that we see in other languages or other key-value stores. Generally, when I show diagrams that represent keys and values, the diagrams have the key name and the type of the value along the top of a box, with the value inside the box. Command used on STRING values Command What it does Fetches the data stored at the given key Sets the value stored at the given key Deletes the value stored at the given key (works for all types) GET SET An example of a STRING, world, stored under a key, hello DEL

  6. 02 Data Structure types Lists in Redis In key-value stores, Redis is unique in that it supports a linked-list structure. LISTs in Redis store an ordered sequence of strings, and like STRINGs. Command used on LIST values Command What it does Pushes the value onto the right end of the list Fetches a range of values from the list RPUSH LRANGE Fetches an item at a given position in the list LINDEX An example of a LIST with three items under the key, list-key Pops the value from the left end of the list and returns it LPOP

  7. 02 Data Structure types In Redis, SETs are similar to LISTs in that they re a sequence of strings, but unlike LISTs, Redis SETs use a hash table to keep all strings unique (though there are no associated values). Because Redis SETs are unordered, we can t push and pop items from the ends like we did with LISTs. Instead, we add and remove items by value with the SADD and SREM commands. We can also find out whether an item is in the SET quickly with SISMEMBER, or fetch the entire set with SMEMBERS (this can be slow for large SETs, so be careful). Sets in Redis Commands used on SET values Command What it does SADD Adds the item to the set SMEMBERS Returns the entire set of items An example of a SET with three items under the key, set-key SISMEMBER Checks if an item is in the set Removes the item from the set, if it exist SREM

  8. 02 Data Structure types Hashes in Redis Redis HASHes store a mapping of keys to values. The values that can be stored in HASHes are the same as what can be stored as normal STRINGs: strings themselves, or if a value can be interpreted as a number, that value can be incremented or decremented. Command used on HASH values Command What it does Stores the value at the key in the hash HSET Fetches the value at the given hash key HGET HGETALL Fetches the entire hash Removes a key from the hash, if it exists HDEL An example of a HASH with two keys/values under the key, hash-key

  9. Data Structure types 02 Like Redis HASHes, ZSETs also hold a type of key and value. The keys (called members) are unique, and the values (called scores) are limited to floating-point numbers. ZSETs have the unique property in Redis of being able to be accessed by member (like a HASH), but items can also be accessed by the sorted order and values of the scores. Zsets in Redis Command used on ZSET values Command What it does Adds member with the given score to the ZSET Fetches the items in the ZSET from their positions in sorted order Fetches items in the ZSET based on a range of scores Removes the item from the ZSET, if it exists ZADD ZRANGE ZRANGEBYSCORE ZREM An example of a ZSET with two members/scores under the key, zset-key

  10. 03 Principle Redis is a Key-Value memory database. All the data is stored in memory in the form of key/value 1. put all the data in memory The speed of disk I/O seriously affects redis performance if data is not stored in memory 2.Single thread If there is only one thread, processing requests in memory can be quick without context switching

  11. 03 Principle Multiple requests may produce different operations concurrently, but IO multiplexers listen to multiple requests , queue the events, and the event dispatcher takes one event from the queue at a time and hands the event over to the corresponding event processor for processing.

  12. Principle 03 The data is in memory. Once server is restarted, the data disappears. We need to back it up to disk 1. RDB Redis will build a snapshot of database 2.AOF Redis will store how we operate database in AOF files

  13. 04 Compared with Memcached 1.Redis not only supports key/value types of data, but also provides more data structures such as list,set,zset,hash. 2.Redis support that the data in memory can be kept on disk and can be reloaded when rebooted. 3.Memcached is multithreading, resulting in performance losses; Redis use single thread and fast speed 4.Redis can realize master-slave replication and data recovery

  14. Redis use cases 05 1. Session cache One of the most apparent use cases for Redis is using it as a session cache. The advantage of using Redis over other session stores, such as Memcached, is that Redis offers persistence. While maintaining a cache isn t typically mission- critical with regards to consistency, most users might be upset if all their cart sessions go away. 2. Full-page cache Outside of your basic session tokens, Redis provides a straightforward Full-page cache (FPC) platform in which to operate. Consistency factors here, too. Even across restarts of Redis instances, with disk persistence, your users don t see a decrease in speed for their page loads a drastic change from something similar to PHP native FPC. 3. Leaderboards and counting Redis does a great job with increments and decrements because it s in-memory. Sets and sorted sets also make our lives easier when we do these kinds of operations. Redis just so happens to offer both of these data structures. 4. Publish-Subscribe Redis has a Publish-Subscribe (Pub/Sub) feature. The use cases for Pub/Sub are boundless. I ve seen people use it for social network connections, for triggering scripts based on Pub/Sub events, and even for a chat system built using Redis Pub/Sub.

  15. Thank you

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#