SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Redis 맛보기
jhoh@encoredtech.com
Redis
● REmote DIctionary Server
● In-memory, but can be persisted
● NoSQL Key-value store
● Written in ANSI C
● No threading, just one process
The Most Popular Key-Value Store
Why Redis?
● Fast
● Easy to learn
● Various data types
● Solve a specific set of problems
○ Good: Caching, Statistical data, Recoverable state,
Worker Queue
○ Bad: 100% consistent dataset required, Data is
larger than memory
Running & Connecting
● redis-server
● redis-cli
● http://try.redis.io/
Redis Protocol
redis[“key”] = “value”
Key
● Redis key is Binary safe, this means that you can use
any binary sequence as a key:
○ string
○ content of a JPEG file
○ also, empty string
Rules about Keys
● Too long keys are not a good idea
○ memory-wise, costly key-comparisons
● Too short keys are often not a good idea
○ more readable
○ id:10:pass => id:10:password
● Try to stick with a schema
○ “object-type:id:field” => “comment:1234:reply.to”
Value types
● String
● List of strings
● Sets of strings
● Sorted sets of strings
● Hashes where keys and values are strings
String
● The simplest Redis type
● A value can’t be bigger than 512 MB
● SET
● GET
● INCR/INCRBY, DECR/DECRBY
● GETSET
127.0.0.1:6379> set mykey 100
OK
127.0.0.1:6379> get mykey
"100"
127.0.0.1:6379> incr mykey
(integer) 101
127.0.0.1:6379> incrby mykey 5
(integer) 106
127.0.0.1:6379> decr mykey
(integer) 105
127.0.0.1:6379> decrby mykey 2
(integer) 103
127.0.0.1:6379> getset mykey 1
"103"
127.0.0.1:6379> get mykey
"1"
Example Of String
List
● Implemented via Linked Lists
● LPUSH
○ add a new element into a list at the head
● RPUSH
○ add a new element into a list at the tail
● LRANGE
127.0.0.1:6379> incr next.news.id
(integer) 1
127.0.0.1:6379> set news:1:title "Redis is simple"
OK
127.0.0.1:6379> set news:1:url "http://code.google.com/redis"
OK
127.0.0.1:6379> lpush submitted.news 1
(integer) 1
Push IDs instead of the actual data
reddit.com example:
Sets
● Unordered collections of unique strings
● SADD
● SMEMBERS
● SISMEMBER
● SINTER
○ the intersection between different sets
Sorted Sets
● Collections of unique strings with associated
score
● ZADD
○ O(log(N))
● ZRANGE/ZREVRANGE
● ZRANGEBYSCORE
ZADD
Add a few selected hackers with their year of birth as score
127.0.0.1:6379> zadd hackers 1940 "Alan Kay"
(integer) 1
127.0.0.1:6379> zadd hackers 1953 "Richard Stallman"
(integer) 1
127.0.0.1:6379> zadd hackers 1965 "Yukihiro Matsumoto"
(integer) 1
127.0.0.1:6379> zadd hackers 1916 "Claude Shannon"
(integer) 1
127.0.0.1:6379> zadd hackers 1969 "Linus Torvalds"
(integer) 1
127.0.0.1:6379> zadd hackers 1912 "Alan Turing"
(integer) 1
ZRANGE/ZREVRANGE
Ask for sorted hackers
127.0.0.1:6379> zrange hackers 0 -1
1) "Alan Turing"
2) "Claude Shannon"
3) "Alan Kay"
4) "Richard Stallman"
5) "Yukihiro Matsumoto"
6) "Linus Torvalds"
127.0.0.1:6379> zrevrange hackers 0 -1
1) "Linus Torvalds"
2) "Yukihiro Matsumoto"
3) "Richard Stallman"
4) "Alan Kay"
5) "Claude Shannon"
6) "Alan Turing"
Sorted Set by different ordering
● Use SORT command
○ Server will waste CPU
● Make another sorted set
○ An alternative for having multiple orders is to add
every element in multiple sorted sets at the same
time.
Updating the scores
● Just calling again ZADD
Hashes
● HSET
● HGET
● HGETALL
● HKEYS
127.0.0.1:6379> hset users:1 username poby
(integer) 1
127.0.0.1:6379> hget users:1 username
"poby"
127.0.0.1:6379> hmset users:1 age 10 bestfriend pororo
OK
127.0.0.1:6379> hgetall users:1
1) "username"
2) "poby"
3) "age"
4) "10"
5) "bestfriend"
6) "pororo"
127.0.0.1:6379> hkeys users:1
1) "username"
2) "age"
3) "bestfriend"
127.0.0.1:6379> hdel users:1 age
(integer) 1
Example Of Hash
Redis Clients
http://redis.io/clients
Demo: realtime-info
AWS ElastiCache
realtime-info
EDM1
EDM1
EDM1
EDM1
EDM1
EDM1
API Server
Log Server
Demo: Realtime-Info (1)
SET realtime-info by Poby
Demo: Realtime-Info (2)
MGET realtime-info by API
참고 자료
● Redis - Wikipedia
● Redis - Fast and Furious
● 15 minutes introduction to Redis data types
● The Little Redis Book
● redis.io
끝

Mais conteúdo relacionado

Destaque

Business Networking-Build a solid network
Business Networking-Build a solid networkBusiness Networking-Build a solid network
Business Networking-Build a solid networkDebbie Gilbert
 
The art of readable code ch4 ch8
The art of readable code ch4   ch8The art of readable code ch4   ch8
The art of readable code ch4 ch8Ki Sung Bae
 
Amazon virtual private cloud (vpc)
Amazon virtual private cloud (vpc)Amazon virtual private cloud (vpc)
Amazon virtual private cloud (vpc)Ki Sung Bae
 
Never stop running in Heidelberg
Never stop running in HeidelbergNever stop running in Heidelberg
Never stop running in HeidelbergNatalieFujitsu
 
The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)Ki Sung Bae
 
Inspirater - Startup Weekend - October 16, 2011
Inspirater - Startup Weekend - October 16, 2011Inspirater - Startup Weekend - October 16, 2011
Inspirater - Startup Weekend - October 16, 2011SWBoston2011
 
Preparandomipruebalacolonia 121024141218-phpapp02
Preparandomipruebalacolonia 121024141218-phpapp02Preparandomipruebalacolonia 121024141218-phpapp02
Preparandomipruebalacolonia 121024141218-phpapp02Starla Smith
 
教育局文明单位工作汇报
教育局文明单位工作汇报教育局文明单位工作汇报
教育局文明单位工作汇报jaychou1986
 
A chinese ppt fans make---10 Ways to Prepare for a TED-format Talk
A chinese ppt fans make---10 Ways to Prepare for a TED-format Talk A chinese ppt fans make---10 Ways to Prepare for a TED-format Talk
A chinese ppt fans make---10 Ways to Prepare for a TED-format Talk jaychou1986
 
The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)Ki Sung Bae
 

Destaque (15)

Business Networking-Build a solid network
Business Networking-Build a solid networkBusiness Networking-Build a solid network
Business Networking-Build a solid network
 
The art of readable code ch4 ch8
The art of readable code ch4   ch8The art of readable code ch4   ch8
The art of readable code ch4 ch8
 
Amazon virtual private cloud (vpc)
Amazon virtual private cloud (vpc)Amazon virtual private cloud (vpc)
Amazon virtual private cloud (vpc)
 
Never stop running in Heidelberg
Never stop running in HeidelbergNever stop running in Heidelberg
Never stop running in Heidelberg
 
Awesome!!!!
Awesome!!!!Awesome!!!!
Awesome!!!!
 
The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)
 
Inspirater - Startup Weekend - October 16, 2011
Inspirater - Startup Weekend - October 16, 2011Inspirater - Startup Weekend - October 16, 2011
Inspirater - Startup Weekend - October 16, 2011
 
Numbers
NumbersNumbers
Numbers
 
Preparandomipruebalacolonia 121024141218-phpapp02
Preparandomipruebalacolonia 121024141218-phpapp02Preparandomipruebalacolonia 121024141218-phpapp02
Preparandomipruebalacolonia 121024141218-phpapp02
 
Kssr matematik
Kssr matematikKssr matematik
Kssr matematik
 
教育局文明单位工作汇报
教育局文明单位工作汇报教育局文明单位工作汇报
教育局文明单位工作汇报
 
A chinese ppt fans make---10 Ways to Prepare for a TED-format Talk
A chinese ppt fans make---10 Ways to Prepare for a TED-format Talk A chinese ppt fans make---10 Ways to Prepare for a TED-format Talk
A chinese ppt fans make---10 Ways to Prepare for a TED-format Talk
 
The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)
 
Tambah 10
Tambah 10Tambah 10
Tambah 10
 
Starbucks
StarbucksStarbucks
Starbucks
 

Semelhante a Redis 맛보기

An Introduction to Redis for Developers.pdf
An Introduction to Redis for Developers.pdfAn Introduction to Redis for Developers.pdf
An Introduction to Redis for Developers.pdfStephen Lorello
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!Daniel Cousineau
 
Florida Man Uses Cache as Database.pdf
Florida Man Uses Cache as Database.pdfFlorida Man Uses Cache as Database.pdf
Florida Man Uses Cache as Database.pdfStephen Lorello
 
Super-Charging Kamailio
Super-Charging KamailioSuper-Charging Kamailio
Super-Charging KamailioAndreas Granig
 
Hybrid Databases - PHP UK Conference 22 February 2019
Hybrid Databases - PHP UK Conference 22 February 2019Hybrid Databases - PHP UK Conference 22 February 2019
Hybrid Databases - PHP UK Conference 22 February 2019Dave Stokes
 
Erasure codes and storage tiers on gluster
Erasure codes and storage tiers on glusterErasure codes and storage tiers on gluster
Erasure codes and storage tiers on glusterRed_Hat_Storage
 
Indexing, searching, and aggregation with redi search and .net
Indexing, searching, and aggregation with redi search and .netIndexing, searching, and aggregation with redi search and .net
Indexing, searching, and aggregation with redi search and .netStephen Lorello
 
RedisConf18 - Redis as a time-series DB
RedisConf18 - Redis as a time-series DBRedisConf18 - Redis as a time-series DB
RedisConf18 - Redis as a time-series DBRedis Labs
 
An Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfAn Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfStephen Lorello
 
Sharding Methods for MongoDB
Sharding Methods for MongoDBSharding Methods for MongoDB
Sharding Methods for MongoDBMongoDB
 
An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAli MasudianPour
 
Neo4j after 1 year in production
Neo4j after 1 year in productionNeo4j after 1 year in production
Neo4j after 1 year in productionAndrew Nikishaev
 
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...Data Con LA
 
RedisConf17 - Searching Billions of Documents with Redis
RedisConf17 - Searching Billions of Documents with RedisRedisConf17 - Searching Billions of Documents with Redis
RedisConf17 - Searching Billions of Documents with RedisRedis Labs
 
The Internet in Database: A Cassandra Use Case
The Internet in Database: A Cassandra Use CaseThe Internet in Database: A Cassandra Use Case
The Internet in Database: A Cassandra Use CaseDatafiniti
 
ORM – The tip of an iceberg
ORM – The tip of an icebergORM – The tip of an iceberg
ORM – The tip of an icebergRafał Hryniewski
 
4Developers 2018: ORM - the tip of an iceberg (Rafał Hryniewski)
4Developers 2018: ORM - the tip of an iceberg (Rafał Hryniewski)4Developers 2018: ORM - the tip of an iceberg (Rafał Hryniewski)
4Developers 2018: ORM - the tip of an iceberg (Rafał Hryniewski)PROIDEA
 

Semelhante a Redis 맛보기 (20)

An Introduction to Redis for Developers.pdf
An Introduction to Redis for Developers.pdfAn Introduction to Redis for Developers.pdf
An Introduction to Redis for Developers.pdf
 
Redis basics
Redis basicsRedis basics
Redis basics
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
 
Florida Man Uses Cache as Database.pdf
Florida Man Uses Cache as Database.pdfFlorida Man Uses Cache as Database.pdf
Florida Man Uses Cache as Database.pdf
 
Super-Charging Kamailio
Super-Charging KamailioSuper-Charging Kamailio
Super-Charging Kamailio
 
Neo4j: Graph-like power
Neo4j: Graph-like powerNeo4j: Graph-like power
Neo4j: Graph-like power
 
Hybrid Databases - PHP UK Conference 22 February 2019
Hybrid Databases - PHP UK Conference 22 February 2019Hybrid Databases - PHP UK Conference 22 February 2019
Hybrid Databases - PHP UK Conference 22 February 2019
 
Erasure codes and storage tiers on gluster
Erasure codes and storage tiers on glusterErasure codes and storage tiers on gluster
Erasure codes and storage tiers on gluster
 
Indexing, searching, and aggregation with redi search and .net
Indexing, searching, and aggregation with redi search and .netIndexing, searching, and aggregation with redi search and .net
Indexing, searching, and aggregation with redi search and .net
 
MongoDB Schema Design Tips & Tricks
MongoDB Schema Design Tips & TricksMongoDB Schema Design Tips & Tricks
MongoDB Schema Design Tips & Tricks
 
RedisConf18 - Redis as a time-series DB
RedisConf18 - Redis as a time-series DBRedisConf18 - Redis as a time-series DB
RedisConf18 - Redis as a time-series DB
 
An Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfAn Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdf
 
Sharding Methods for MongoDB
Sharding Methods for MongoDBSharding Methods for MongoDB
Sharding Methods for MongoDB
 
An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL database
 
Neo4j after 1 year in production
Neo4j after 1 year in productionNeo4j after 1 year in production
Neo4j after 1 year in production
 
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...
 
RedisConf17 - Searching Billions of Documents with Redis
RedisConf17 - Searching Billions of Documents with RedisRedisConf17 - Searching Billions of Documents with Redis
RedisConf17 - Searching Billions of Documents with Redis
 
The Internet in Database: A Cassandra Use Case
The Internet in Database: A Cassandra Use CaseThe Internet in Database: A Cassandra Use Case
The Internet in Database: A Cassandra Use Case
 
ORM – The tip of an iceberg
ORM – The tip of an icebergORM – The tip of an iceberg
ORM – The tip of an iceberg
 
4Developers 2018: ORM - the tip of an iceberg (Rafał Hryniewski)
4Developers 2018: ORM - the tip of an iceberg (Rafał Hryniewski)4Developers 2018: ORM - the tip of an iceberg (Rafał Hryniewski)
4Developers 2018: ORM - the tip of an iceberg (Rafał Hryniewski)
 

Último

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 

Último (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

Redis 맛보기

  • 2. Redis ● REmote DIctionary Server ● In-memory, but can be persisted ● NoSQL Key-value store ● Written in ANSI C ● No threading, just one process
  • 3. The Most Popular Key-Value Store
  • 4. Why Redis? ● Fast ● Easy to learn ● Various data types ● Solve a specific set of problems ○ Good: Caching, Statistical data, Recoverable state, Worker Queue ○ Bad: 100% consistent dataset required, Data is larger than memory
  • 5. Running & Connecting ● redis-server ● redis-cli ● http://try.redis.io/
  • 7. Key ● Redis key is Binary safe, this means that you can use any binary sequence as a key: ○ string ○ content of a JPEG file ○ also, empty string
  • 8. Rules about Keys ● Too long keys are not a good idea ○ memory-wise, costly key-comparisons ● Too short keys are often not a good idea ○ more readable ○ id:10:pass => id:10:password ● Try to stick with a schema ○ “object-type:id:field” => “comment:1234:reply.to”
  • 9. Value types ● String ● List of strings ● Sets of strings ● Sorted sets of strings ● Hashes where keys and values are strings
  • 10. String ● The simplest Redis type ● A value can’t be bigger than 512 MB ● SET ● GET ● INCR/INCRBY, DECR/DECRBY ● GETSET
  • 11. 127.0.0.1:6379> set mykey 100 OK 127.0.0.1:6379> get mykey "100" 127.0.0.1:6379> incr mykey (integer) 101 127.0.0.1:6379> incrby mykey 5 (integer) 106 127.0.0.1:6379> decr mykey (integer) 105 127.0.0.1:6379> decrby mykey 2 (integer) 103 127.0.0.1:6379> getset mykey 1 "103" 127.0.0.1:6379> get mykey "1" Example Of String
  • 12. List ● Implemented via Linked Lists ● LPUSH ○ add a new element into a list at the head ● RPUSH ○ add a new element into a list at the tail ● LRANGE
  • 13. 127.0.0.1:6379> incr next.news.id (integer) 1 127.0.0.1:6379> set news:1:title "Redis is simple" OK 127.0.0.1:6379> set news:1:url "http://code.google.com/redis" OK 127.0.0.1:6379> lpush submitted.news 1 (integer) 1 Push IDs instead of the actual data reddit.com example:
  • 14. Sets ● Unordered collections of unique strings ● SADD ● SMEMBERS ● SISMEMBER ● SINTER ○ the intersection between different sets
  • 15. Sorted Sets ● Collections of unique strings with associated score ● ZADD ○ O(log(N)) ● ZRANGE/ZREVRANGE ● ZRANGEBYSCORE
  • 16. ZADD Add a few selected hackers with their year of birth as score 127.0.0.1:6379> zadd hackers 1940 "Alan Kay" (integer) 1 127.0.0.1:6379> zadd hackers 1953 "Richard Stallman" (integer) 1 127.0.0.1:6379> zadd hackers 1965 "Yukihiro Matsumoto" (integer) 1 127.0.0.1:6379> zadd hackers 1916 "Claude Shannon" (integer) 1 127.0.0.1:6379> zadd hackers 1969 "Linus Torvalds" (integer) 1 127.0.0.1:6379> zadd hackers 1912 "Alan Turing" (integer) 1
  • 17. ZRANGE/ZREVRANGE Ask for sorted hackers 127.0.0.1:6379> zrange hackers 0 -1 1) "Alan Turing" 2) "Claude Shannon" 3) "Alan Kay" 4) "Richard Stallman" 5) "Yukihiro Matsumoto" 6) "Linus Torvalds" 127.0.0.1:6379> zrevrange hackers 0 -1 1) "Linus Torvalds" 2) "Yukihiro Matsumoto" 3) "Richard Stallman" 4) "Alan Kay" 5) "Claude Shannon" 6) "Alan Turing"
  • 18. Sorted Set by different ordering ● Use SORT command ○ Server will waste CPU ● Make another sorted set ○ An alternative for having multiple orders is to add every element in multiple sorted sets at the same time.
  • 19. Updating the scores ● Just calling again ZADD
  • 20. Hashes ● HSET ● HGET ● HGETALL ● HKEYS
  • 21. 127.0.0.1:6379> hset users:1 username poby (integer) 1 127.0.0.1:6379> hget users:1 username "poby" 127.0.0.1:6379> hmset users:1 age 10 bestfriend pororo OK 127.0.0.1:6379> hgetall users:1 1) "username" 2) "poby" 3) "age" 4) "10" 5) "bestfriend" 6) "pororo" 127.0.0.1:6379> hkeys users:1 1) "username" 2) "age" 3) "bestfriend" 127.0.0.1:6379> hdel users:1 age (integer) 1 Example Of Hash
  • 24. Demo: Realtime-Info (1) SET realtime-info by Poby
  • 25. Demo: Realtime-Info (2) MGET realtime-info by API
  • 26. 참고 자료 ● Redis - Wikipedia ● Redis - Fast and Furious ● 15 minutes introduction to Redis data types ● The Little Redis Book ● redis.io
  • 27.