SlideShare a Scribd company logo
Redis​ ​Cheat​ ​Sheet 
Objects​ ​in​ ​Redis 
● must​ ​have​ ​a​ ​key 
● keys​ ​are​ ​colon​ ​separated 
● value​ ​can​ ​be​ ​hash,​ ​set,​ ​list,​ ​sortedset,​ ​string 
● can​ ​have​ ​an​ ​expiry 
   
Hashes: 
● Use​ ​to​ ​store​ ​"objects"​ ​from​ ​object​ ​oriented​ ​programming 
"blogs:234":​ ​{
​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​"id":​ ​234,
​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​"title":​ ​"Introduction​ ​to​ ​Redis",
​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​"views":​ ​1024
​ ​​ ​​ ​​ ​​ ​​ ​}
● hmset​ ​blogs:234​ ​id​ ​234​ ​title​ ​"Introduction​ ​to​ ​Redis"​ ​views​ ​1024 
● hgetall​ ​blogs:234 
● hincrby​ ​blogs:234​ ​views​ ​1 
 
Sets: 
● Only​ ​unique​ ​items.​ ​No​ ​duplicates 
● Elements​ ​are​ ​not​ ​ordered 
● Can​ ​check​ ​if​ ​element​ ​exists​ ​very​ ​quickly 
● Use​ ​case:​ ​Count​ ​unique​ ​items 
● Use​ ​case:​ ​Check​ ​if​ ​item​ ​exists 
● Use​ ​case:​ ​Perform​ ​logical​ ​UNION​ ​/​ ​INTERSECTION​ ​operations 
● Two​ ​ways​ ​to​ ​represent​ ​same​ ​information,​ ​choose​ ​based​ ​on​ ​use 
case​ ​set​ ​of​ ​integers​ ​consumes​ ​less​ ​memory,​ ​is​ ​very​ ​efficient 
"blogs:234:tags"​ ​==>​ ​set("aws",​ ​"redis",​ ​"cache")
v/s
"tags:aws:blogs"​ ​==>​ ​set(234,​ ​532,​ ​332)
Lists: 
● Duplicates​ ​allowed.  
● Very​ ​well​ ​defined​ ​order​ ​of​ ​elements 
● Expensive​ ​to​ ​check​ ​if​ ​element​ ​already​ ​exists​ ​in​ ​list 
©​ ​2017​ ​HashedIn​ ​Technologies​ ​Pvt.​ ​Ltd. 
● Operations​ ​near​ ​head​ ​/​ ​tail​ ​very​ ​fast. 
● Operations​ ​near​ ​centre​ ​elements​ ​slower 
● Can​ ​use​ ​as​ ​a​ ​queue​ ​or​ ​a​ ​stack 
● Operations​ ​can​ ​block​ ​if​ ​no​ ​elements​ ​are​ ​available,​ ​useful 
● Easy​ ​to​ ​restrict​ ​length​ ​using​ ​ltrim​ ​command 
● Use​ ​case:​ ​Recent​ ​items,​ ​recent​ ​logs 
● Use​ ​case:​ ​Queue​ ​to​ ​maintain​ ​tasks 
 
Sorted​ ​Sets 
● Like​ ​a​ ​set,​ ​only​ ​allows​ ​unique​ ​items 
● Every​ ​element​ ​can​ ​have​ ​a​ ​numeric​ ​score 
● Score​ ​can​ ​represent​ ​anything​ ​-​ ​sales,​ ​count​ ​of​ ​orders,​ ​points​ ​in 
a​ ​game​ ​etc. 
● Elements​ ​are​ ​always​ ​maintained​ ​in​ ​order​ ​of​ ​score  
● If​ ​score​ ​of​ ​two​ ​elements​ ​are​ ​same,​ ​elements​ ​are​ ​sorted​ ​in 
lexicographical​ ​order​ ​-​ ​the​ ​way​ ​you​ ​see​ ​in​ ​oxford's​ ​dictionary 
● Use​ ​case:​ ​Leader​ ​boards​ ​-​ ​Top​ ​10​ ​players,​ ​Products​ ​with​ ​least 
sales,  
● Use​ ​case:​ ​Autocomplete​ ​API  
Strings: 
● Strings​ ​are​ ​binary,​ ​and​ ​can​ ​store​ ​integers,​ ​floats,​ ​text 
● You​ ​can​ ​treat​ ​the​ ​string​ ​as​ ​a​ ​very​ ​large​ ​bitmap 
● You​ ​can​ ​split​ ​the​ ​string​ ​into​ ​smaller​ ​fields,​ ​and​ ​then​ ​set/get 
each​ ​field​ ​using​ ​the​ ​bitfield​ ​command 
 
©​ ​2017​ ​HashedIn​ ​Technologies​ ​Pvt.​ ​Ltd. 

More Related Content

Similar to Redis Cheat Sheet

Mongodb Performance
Mongodb PerformanceMongodb Performance
Mongodb Performance
Jack
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
Dvir Volk
 
Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017
HashedIn Technologies
 
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
Stephen Lorello
 
Text search with Elasticsearch on AWS
Text search with Elasticsearch on AWSText search with Elasticsearch on AWS
Text search with Elasticsearch on AWS
Łukasz Przybyłek
 
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATESPyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
Alessandro Molina
 
PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013Andrew Dunstan
 
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
Command Prompt., Inc
 
PostgreSQL - Object Relational Database
PostgreSQL - Object Relational DatabasePostgreSQL - Object Relational Database
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
Introduction to AWS Big Data
Introduction to AWS Big Data Introduction to AWS Big Data
Introduction to AWS Big Data
Omid Vahdaty
 
Discovering python search engine
Discovering python search engineDiscovering python search engine
Discovering python search engine
Jose Manuel Ortega Candel
 
Journey through high performance django application
Journey through high performance django applicationJourney through high performance django application
Journey through high performance django application
bangaloredjangousergroup
 
AWS Big Data Demystified #2 | Athena, Spectrum, Emr, Hive
AWS Big Data Demystified #2 |  Athena, Spectrum, Emr, Hive AWS Big Data Demystified #2 |  Athena, Spectrum, Emr, Hive
AWS Big Data Demystified #2 | Athena, Spectrum, Emr, Hive
Omid Vahdaty
 
Elasticsearch selected topics
Elasticsearch selected topicsElasticsearch selected topics
Elasticsearch selected topics
Cube Solutions
 
Work Stealing For Fun & Profit: Jim Nelson
Work Stealing For Fun & Profit: Jim NelsonWork Stealing For Fun & Profit: Jim Nelson
Work Stealing For Fun & Profit: Jim Nelson
Redis Labs
 
Introducing Datawave
Introducing DatawaveIntroducing Datawave
Introducing Datawave
Accumulo Summit
 
PostgreSQL and Sphinx pgcon 2013
PostgreSQL and Sphinx   pgcon 2013PostgreSQL and Sphinx   pgcon 2013
PostgreSQL and Sphinx pgcon 2013
Emanuel Calvo
 
Redis basics
Redis basicsRedis basics
Redis basics
Arthur Shvetsov
 
Amazon DynamoDB Lessen's Learned by Beginner
Amazon DynamoDB Lessen's Learned by BeginnerAmazon DynamoDB Lessen's Learned by Beginner
Amazon DynamoDB Lessen's Learned by Beginner
Hirokazu Tokuno
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Rizky Abdilah
 

Similar to Redis Cheat Sheet (20)

Mongodb Performance
Mongodb PerformanceMongodb Performance
Mongodb Performance
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
 
Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017
 
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
 
Text search with Elasticsearch on AWS
Text search with Elasticsearch on AWSText search with Elasticsearch on AWS
Text search with Elasticsearch on AWS
 
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATESPyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
 
PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013
 
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
 
PostgreSQL - Object Relational Database
PostgreSQL - Object Relational DatabasePostgreSQL - Object Relational Database
PostgreSQL - Object Relational Database
 
Introduction to AWS Big Data
Introduction to AWS Big Data Introduction to AWS Big Data
Introduction to AWS Big Data
 
Discovering python search engine
Discovering python search engineDiscovering python search engine
Discovering python search engine
 
Journey through high performance django application
Journey through high performance django applicationJourney through high performance django application
Journey through high performance django application
 
AWS Big Data Demystified #2 | Athena, Spectrum, Emr, Hive
AWS Big Data Demystified #2 |  Athena, Spectrum, Emr, Hive AWS Big Data Demystified #2 |  Athena, Spectrum, Emr, Hive
AWS Big Data Demystified #2 | Athena, Spectrum, Emr, Hive
 
Elasticsearch selected topics
Elasticsearch selected topicsElasticsearch selected topics
Elasticsearch selected topics
 
Work Stealing For Fun & Profit: Jim Nelson
Work Stealing For Fun & Profit: Jim NelsonWork Stealing For Fun & Profit: Jim Nelson
Work Stealing For Fun & Profit: Jim Nelson
 
Introducing Datawave
Introducing DatawaveIntroducing Datawave
Introducing Datawave
 
PostgreSQL and Sphinx pgcon 2013
PostgreSQL and Sphinx   pgcon 2013PostgreSQL and Sphinx   pgcon 2013
PostgreSQL and Sphinx pgcon 2013
 
Redis basics
Redis basicsRedis basics
Redis basics
 
Amazon DynamoDB Lessen's Learned by Beginner
Amazon DynamoDB Lessen's Learned by BeginnerAmazon DynamoDB Lessen's Learned by Beginner
Amazon DynamoDB Lessen's Learned by Beginner
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 

Recently uploaded

Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 

Recently uploaded (20)

Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 

Redis Cheat Sheet

  • 1. Redis​ ​Cheat​ ​Sheet  Objects​ ​in​ ​Redis  ● must​ ​have​ ​a​ ​key  ● keys​ ​are​ ​colon​ ​separated  ● value​ ​can​ ​be​ ​hash,​ ​set,​ ​list,​ ​sortedset,​ ​string  ● can​ ​have​ ​an​ ​expiry      Hashes:  ● Use​ ​to​ ​store​ ​"objects"​ ​from​ ​object​ ​oriented​ ​programming  "blogs:234":​ ​{ ​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​"id":​ ​234, ​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​"title":​ ​"Introduction​ ​to​ ​Redis", ​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​"views":​ ​1024 ​ ​​ ​​ ​​ ​​ ​​ ​} ● hmset​ ​blogs:234​ ​id​ ​234​ ​title​ ​"Introduction​ ​to​ ​Redis"​ ​views​ ​1024  ● hgetall​ ​blogs:234  ● hincrby​ ​blogs:234​ ​views​ ​1    Sets:  ● Only​ ​unique​ ​items.​ ​No​ ​duplicates  ● Elements​ ​are​ ​not​ ​ordered  ● Can​ ​check​ ​if​ ​element​ ​exists​ ​very​ ​quickly  ● Use​ ​case:​ ​Count​ ​unique​ ​items  ● Use​ ​case:​ ​Check​ ​if​ ​item​ ​exists  ● Use​ ​case:​ ​Perform​ ​logical​ ​UNION​ ​/​ ​INTERSECTION​ ​operations  ● Two​ ​ways​ ​to​ ​represent​ ​same​ ​information,​ ​choose​ ​based​ ​on​ ​use  case​ ​set​ ​of​ ​integers​ ​consumes​ ​less​ ​memory,​ ​is​ ​very​ ​efficient  "blogs:234:tags"​ ​==>​ ​set("aws",​ ​"redis",​ ​"cache") v/s "tags:aws:blogs"​ ​==>​ ​set(234,​ ​532,​ ​332) Lists:  ● Duplicates​ ​allowed.   ● Very​ ​well​ ​defined​ ​order​ ​of​ ​elements  ● Expensive​ ​to​ ​check​ ​if​ ​element​ ​already​ ​exists​ ​in​ ​list  ©​ ​2017​ ​HashedIn​ ​Technologies​ ​Pvt.​ ​Ltd. 
  • 2. ● Operations​ ​near​ ​head​ ​/​ ​tail​ ​very​ ​fast.  ● Operations​ ​near​ ​centre​ ​elements​ ​slower  ● Can​ ​use​ ​as​ ​a​ ​queue​ ​or​ ​a​ ​stack  ● Operations​ ​can​ ​block​ ​if​ ​no​ ​elements​ ​are​ ​available,​ ​useful  ● Easy​ ​to​ ​restrict​ ​length​ ​using​ ​ltrim​ ​command  ● Use​ ​case:​ ​Recent​ ​items,​ ​recent​ ​logs  ● Use​ ​case:​ ​Queue​ ​to​ ​maintain​ ​tasks    Sorted​ ​Sets  ● Like​ ​a​ ​set,​ ​only​ ​allows​ ​unique​ ​items  ● Every​ ​element​ ​can​ ​have​ ​a​ ​numeric​ ​score  ● Score​ ​can​ ​represent​ ​anything​ ​-​ ​sales,​ ​count​ ​of​ ​orders,​ ​points​ ​in  a​ ​game​ ​etc.  ● Elements​ ​are​ ​always​ ​maintained​ ​in​ ​order​ ​of​ ​score   ● If​ ​score​ ​of​ ​two​ ​elements​ ​are​ ​same,​ ​elements​ ​are​ ​sorted​ ​in  lexicographical​ ​order​ ​-​ ​the​ ​way​ ​you​ ​see​ ​in​ ​oxford's​ ​dictionary  ● Use​ ​case:​ ​Leader​ ​boards​ ​-​ ​Top​ ​10​ ​players,​ ​Products​ ​with​ ​least  sales,   ● Use​ ​case:​ ​Autocomplete​ ​API   Strings:  ● Strings​ ​are​ ​binary,​ ​and​ ​can​ ​store​ ​integers,​ ​floats,​ ​text  ● You​ ​can​ ​treat​ ​the​ ​string​ ​as​ ​a​ ​very​ ​large​ ​bitmap  ● You​ ​can​ ​split​ ​the​ ​string​ ​into​ ​smaller​ ​fields,​ ​and​ ​then​ ​set/get  each​ ​field​ ​using​ ​the​ ​bitfield​ ​command    ©​ ​2017​ ​HashedIn​ ​Technologies​ ​Pvt.​ ​Ltd.