SlideShare ist ein Scribd-Unternehmen logo
1 von 17
1
REDIS SERVER
An Introduction to REDIS SERVER, an advanced key value
database
By: Ali MasudianPour <masud.amp@gmail.com>
2
What REDIS is
●
Redis is an open source, BSD licensed, advanced key-value
store. It is often referred to as a data structure server since keys
can contain strings, hashes, lists, sets and sorted sets.
●
REDIS
– It stands for REmote DIctionary Server
3
Features
●
not a plain key-value store, a data structures server
●
supporting different kind of values
●
Free and open source
●
Easy to user
●
Easy to learn
4
Supported Data Types
●
Binary-safe strings.
●
Lists of binary-safe strings.
●
Sets of binary-safe strings, that are collection of unique unsorted
elements.
●
Sorted sets, similar to Sets but where every element is
associated to a floating number score. The elements are taken
sorted by score.
5
KEYS - VALUES
●
In REDIS, Keys are binary safe
– This means that you can use any binary sequence as key
●
From String like 'foo' to the content of a JPEG file
– REDIS keys accept empty
●
In REDIS, Values
– Can not be bigger than 512MB
–
6
SET
●
To set a value to a key we use SET statement
– SET key value
●
Example:
– SET foo bar
– In above example we told redis to set bar value to foo key
●
To set string value we use double quotations
– SET keyname “The string content of value”
7
GET
●
To get a value from redis we use GET statement
– GET keyname
●
Example
– GET foo // it will return bar
– In above example we told redis to get foo key value.
8
INCR, INCRBY
●
Automatic increment by REDIS
– To use automatic increment of redis we use INCR
●
Example:
– Set counter 1
incr counter
// Output wil be 2
●
We can also use INCRBY
– Set counter 1
– Incr counter
– // Output wil be 2
– Incrby counter 10
– //outpur will be 12
9
DECR, DECRBY
●
In opposite of INCR and INCRBY redis contains DESC and
DESCBY
– Just like DECR and DECRBY
– Set counter 10
decr counter
// Output wil be 9
decrby counter 5
//output will be 4
10
EXPIRE and TTL
●
In REDIS we can set keys to expire in a given and specific
amount of time.
– To do that we use EXPIRE command
– Example
●
Set foo bar
●
Expire foo 50
– To find out how many time a key have we use TTL command
●
For instance after 10 second of declaring foo key if we use TTL command the
output will be something like below:
– Ttl foo
//40
11
LISTS
●
To create a list use LPUSH or RPUSH. If a list already exists,
LPUSH will add the given value to the beginning of the list and
RPUSH will add it to the end.
●
Redis lists contain the following commands
– SORT
– RPUSH
– LPUSH
– LLEN
– LTRIM
– LRANGE
– LPOP
– RPOP
– BLPOP
– BRPOP
–
12
LISTS
redis 127.0.0.1:6379> lpush ages 10
(integer) 1
redis 127.0.0.1:6379> lpush ages 13
(integer) 2
redis 127.0.0.1:6379> lpush ages 12
(integer) 3
redis 127.0.0.1:6379> lpush ages 6
(integer) 4
redis 127.0.0.1:6379> LRANGE ages 0 3
1) "6"
2) "12"
3) "13"
4) "10"
redis 127.0.0.1:6379> sort ages
1) "6"
2) "10"
3) "12"
4) "13"
-----------------------------
redis 127.0.0.1:6379> lpop ages
"6"
redis 127.0.0.1:6379> rpop ages
"10"
redis 127.0.0.1:6379> LRANGE ages 0 10
1) "12"
2) "13"
redis 127.0.0.1:6379>
13
SETS
●
Sets are similar to lists but does not support duplication
●
Example:
– Add to sets
●
redis 127.0.0.1:6379> SADD names "Michael"
(integer) 1
redis 127.0.0.1:6379> SADD names "JOHN"
(integer) 1
redis 127.0.0.1:6379> SMEMBERS names
1) "JOHN"
2) "Michael"
14
Lists
●
Now, if you try to add another set member with JOHN value it
will do nothing, because sets do not support duplication.
●
Other useful commands for set
– SADD, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER,
SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE,
SMEMBERS, SRANDMEMBER.
15
HASHES
●
Using a hash, you can assign values to fields in each key.
●
Common Commands in hashes are:
– HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS,
HDEL, HLEN, HKEYS, HVALS, HGETALL
16
Example of HASHESredis 127.0.0.1:6379> hset student name "Ali"
(integer) 1
redis 127.0.0.1:6379> hset student lastName "MasudianPour"
(integer) 1
redis 127.0.0.1:6379> hset student number 101222
(integer) 1
redis 127.0.0.1:6379> hget student name
"Ali"
redis 127.0.0.1:6379> hget student lastName
"MasudianPour"
redis 127.0.0.1:6379> HGETALL student
1) "name"
2) "Ali"
3) "lastName"
4) "MasudianPour"
17
End
●
This document is provided to be a little familiar with REDIS. I
hope it help you to start working with REDIS.

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisArnab Mitra
 
Caching solutions with Redis
Caching solutions   with RedisCaching solutions   with Redis
Caching solutions with RedisGeorge Platon
 
A simple introduction to redis
A simple introduction to redisA simple introduction to redis
A simple introduction to redisZhichao Liang
 
Redis cluster
Redis clusterRedis cluster
Redis clusteriammutex
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in PracticeNoah Davis
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2Dvir Volk
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redisKris Jeong
 
Redis persistence in practice
Redis persistence in practiceRedis persistence in practice
Redis persistence in practiceEugene Fidelin
 
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
 
Introduction of Redis as NoSQL Database
Introduction of Redis as NoSQL DatabaseIntroduction of Redis as NoSQL Database
Introduction of Redis as NoSQL DatabaseAbhijeet Shekhar
 
Redis Overview
Redis OverviewRedis Overview
Redis OverviewHoang Long
 
Paris Redis Meetup Introduction
Paris Redis Meetup IntroductionParis Redis Meetup Introduction
Paris Redis Meetup IntroductionGregory Boissinot
 
Using Apache Hive with High Performance
Using Apache Hive with High PerformanceUsing Apache Hive with High Performance
Using Apache Hive with High PerformanceInderaj (Raj) Bains
 

Was ist angesagt? (20)

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Caching solutions with Redis
Caching solutions   with RedisCaching solutions   with Redis
Caching solutions with Redis
 
A simple introduction to redis
A simple introduction to redisA simple introduction to redis
A simple introduction to redis
 
Redis and it's data types
Redis and it's data typesRedis and it's data types
Redis and it's data types
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in Practice
 
Redis Persistence
Redis  PersistenceRedis  Persistence
Redis Persistence
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
 
Redis database
Redis databaseRedis database
Redis database
 
Redis
RedisRedis
Redis
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redis
 
Redis persistence in practice
Redis persistence in practiceRedis persistence in practice
Redis persistence in practice
 
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
 
Introduction of Redis as NoSQL Database
Introduction of Redis as NoSQL DatabaseIntroduction of Redis as NoSQL Database
Introduction of Redis as NoSQL Database
 
Redis Overview
Redis OverviewRedis Overview
Redis Overview
 
Redis basics
Redis basicsRedis basics
Redis basics
 
Paris Redis Meetup Introduction
Paris Redis Meetup IntroductionParis Redis Meetup Introduction
Paris Redis Meetup Introduction
 
Redis 101
Redis 101Redis 101
Redis 101
 
Redis
RedisRedis
Redis
 
Using Apache Hive with High Performance
Using Apache Hive with High PerformanceUsing Apache Hive with High Performance
Using Apache Hive with High Performance
 

Andere mochten auch

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisDvir Volk
 
Redis Installation Configuration And Implementation
Redis Installation Configuration And ImplementationRedis Installation Configuration And Implementation
Redis Installation Configuration And ImplementationAbhijeet Shekhar
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redisDvir Volk
 
Redis replication dcshi
Redis replication dcshiRedis replication dcshi
Redis replication dcshidcshi
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011sunilar0ra
 
Ancient Rome And Present Italy
Ancient Rome And Present ItalyAncient Rome And Present Italy
Ancient Rome And Present Italyguestb044ec
 
REDIS caching explained
REDIS caching explained REDIS caching explained
REDIS caching explained Dan Rinzel
 
Using Redis at Facebook
Using Redis at FacebookUsing Redis at Facebook
Using Redis at FacebookRedis Labs
 
Redis data design by usecase
Redis data design by usecaseRedis data design by usecase
Redis data design by usecaseKris Jeong
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examplesTerry Cho
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Itamar Haber
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsSolution4Future
 
唯品会大数据实践 Sacc pub
唯品会大数据实践 Sacc pub唯品会大数据实践 Sacc pub
唯品会大数据实践 Sacc pubChao Zhu
 
Building Automated REST APIs with Python
Building Automated REST APIs with PythonBuilding Automated REST APIs with Python
Building Automated REST APIs with PythonJeff Knupp
 
ReST (Representational State Transfer) Explained
ReST (Representational State Transfer) ExplainedReST (Representational State Transfer) Explained
ReST (Representational State Transfer) ExplainedDhananjay Nene
 

Andere mochten auch (20)

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Redis Installation Configuration And Implementation
Redis Installation Configuration And ImplementationRedis Installation Configuration And Implementation
Redis Installation Configuration And Implementation
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 
Redis
RedisRedis
Redis
 
Redis replication dcshi
Redis replication dcshiRedis replication dcshi
Redis replication dcshi
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Lightning Hedis
Lightning HedisLightning Hedis
Lightning Hedis
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011
 
Ancient Rome And Present Italy
Ancient Rome And Present ItalyAncient Rome And Present Italy
Ancient Rome And Present Italy
 
REDIS caching explained
REDIS caching explained REDIS caching explained
REDIS caching explained
 
Using Redis at Facebook
Using Redis at FacebookUsing Redis at Facebook
Using Redis at Facebook
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
Redis data design by usecase
Redis data design by usecaseRedis data design by usecase
Redis data design by usecase
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examples
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
 
唯品会大数据实践 Sacc pub
唯品会大数据实践 Sacc pub唯品会大数据实践 Sacc pub
唯品会大数据实践 Sacc pub
 
Building Automated REST APIs with Python
Building Automated REST APIs with PythonBuilding Automated REST APIs with Python
Building Automated REST APIs with Python
 
RESTful API Design, Second Edition
RESTful API Design, Second EditionRESTful API Design, Second Edition
RESTful API Design, Second Edition
 
ReST (Representational State Transfer) Explained
ReST (Representational State Transfer) ExplainedReST (Representational State Transfer) Explained
ReST (Representational State Transfer) Explained
 

Ähnlich wie An Introduction to REDIS NoSQL database

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisItamar Haber
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisRizky Abdilah
 
#SydPHP - The Magic of Redis
#SydPHP - The Magic of Redis#SydPHP - The Magic of Redis
#SydPHP - The Magic of RedisAaron Weatherall
 
Serializing Ruby Objects in Redis
Serializing Ruby Objects in RedisSerializing Ruby Objects in Redis
Serializing Ruby Objects in RedisBrian Kaney
 
Redis SoCraTes 2014
Redis SoCraTes 2014Redis SoCraTes 2014
Redis SoCraTes 2014steffenbauer
 
A Brief Introduction to Redis
A Brief Introduction to RedisA Brief Introduction to Redis
A Brief Introduction to RedisCharles Anderson
 
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Andrew Lavers
 
Fun with Ruby and Redis
Fun with Ruby and RedisFun with Ruby and Redis
Fun with Ruby and Redisjavier ramirez
 
C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101Bellaj Badr
 
Redis: REmote DIctionary Server
Redis: REmote DIctionary ServerRedis: REmote DIctionary Server
Redis: REmote DIctionary ServerEzra Zygmuntowicz
 
Speed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with RedisSpeed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with RedisRicard Clau
 
Redis Functions, Data Structures for Web Scale Apps
Redis Functions, Data Structures for Web Scale AppsRedis Functions, Data Structures for Web Scale Apps
Redis Functions, Data Structures for Web Scale AppsDave Nielsen
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisKnoldus Inc.
 

Ähnlich wie An Introduction to REDIS NoSQL database (20)

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Redis overview
Redis overviewRedis overview
Redis overview
 
Redis Set Go
Redis Set GoRedis Set Go
Redis Set Go
 
#SydPHP - The Magic of Redis
#SydPHP - The Magic of Redis#SydPHP - The Magic of Redis
#SydPHP - The Magic of Redis
 
Serializing Ruby Objects in Redis
Serializing Ruby Objects in RedisSerializing Ruby Objects in Redis
Serializing Ruby Objects in Redis
 
Redis SoCraTes 2014
Redis SoCraTes 2014Redis SoCraTes 2014
Redis SoCraTes 2014
 
Seminar_Final
Seminar_FinalSeminar_Final
Seminar_Final
 
A Brief Introduction to Redis
A Brief Introduction to RedisA Brief Introduction to Redis
A Brief Introduction to Redis
 
REDIS327
REDIS327REDIS327
REDIS327
 
Redis Lua Scripts
Redis Lua ScriptsRedis Lua Scripts
Redis Lua Scripts
 
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
 
Fun with Ruby and Redis
Fun with Ruby and RedisFun with Ruby and Redis
Fun with Ruby and Redis
 
Mini-Training: Redis
Mini-Training: RedisMini-Training: Redis
Mini-Training: Redis
 
C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101
 
Redis: REmote DIctionary Server
Redis: REmote DIctionary ServerRedis: REmote DIctionary Server
Redis: REmote DIctionary Server
 
Speed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with RedisSpeed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with Redis
 
Redis Functions, Data Structures for Web Scale Apps
Redis Functions, Data Structures for Web Scale AppsRedis Functions, Data Structures for Web Scale Apps
Redis Functions, Data Structures for Web Scale Apps
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Redis acc 2015_eng
Redis acc 2015_engRedis acc 2015_eng
Redis acc 2015_eng
 

Mehr von Ali MasudianPour

Rapid postgresql learning, part 4
Rapid postgresql learning, part 4Rapid postgresql learning, part 4
Rapid postgresql learning, part 4Ali MasudianPour
 
Rapid postgresql learning, part 3
Rapid postgresql learning, part 3Rapid postgresql learning, part 3
Rapid postgresql learning, part 3Ali MasudianPour
 
Rapid postgresql learning, part 2
Rapid postgresql learning, part 2Rapid postgresql learning, part 2
Rapid postgresql learning, part 2Ali MasudianPour
 
Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Ali MasudianPour
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and JavaAli MasudianPour
 
Xp exterme-programming-model
Xp exterme-programming-modelXp exterme-programming-model
Xp exterme-programming-modelAli MasudianPour
 

Mehr von Ali MasudianPour (7)

Start using less css
Start using less cssStart using less css
Start using less css
 
Rapid postgresql learning, part 4
Rapid postgresql learning, part 4Rapid postgresql learning, part 4
Rapid postgresql learning, part 4
 
Rapid postgresql learning, part 3
Rapid postgresql learning, part 3Rapid postgresql learning, part 3
Rapid postgresql learning, part 3
 
Rapid postgresql learning, part 2
Rapid postgresql learning, part 2Rapid postgresql learning, part 2
Rapid postgresql learning, part 2
 
Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Rapid postgresql learning, part 1
Rapid postgresql learning, part 1
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and Java
 
Xp exterme-programming-model
Xp exterme-programming-modelXp exterme-programming-model
Xp exterme-programming-model
 

Kürzlich hochgeladen

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

An Introduction to REDIS NoSQL database

  • 1. 1 REDIS SERVER An Introduction to REDIS SERVER, an advanced key value database By: Ali MasudianPour <masud.amp@gmail.com>
  • 2. 2 What REDIS is ● Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. ● REDIS – It stands for REmote DIctionary Server
  • 3. 3 Features ● not a plain key-value store, a data structures server ● supporting different kind of values ● Free and open source ● Easy to user ● Easy to learn
  • 4. 4 Supported Data Types ● Binary-safe strings. ● Lists of binary-safe strings. ● Sets of binary-safe strings, that are collection of unique unsorted elements. ● Sorted sets, similar to Sets but where every element is associated to a floating number score. The elements are taken sorted by score.
  • 5. 5 KEYS - VALUES ● In REDIS, Keys are binary safe – This means that you can use any binary sequence as key ● From String like 'foo' to the content of a JPEG file – REDIS keys accept empty ● In REDIS, Values – Can not be bigger than 512MB –
  • 6. 6 SET ● To set a value to a key we use SET statement – SET key value ● Example: – SET foo bar – In above example we told redis to set bar value to foo key ● To set string value we use double quotations – SET keyname “The string content of value”
  • 7. 7 GET ● To get a value from redis we use GET statement – GET keyname ● Example – GET foo // it will return bar – In above example we told redis to get foo key value.
  • 8. 8 INCR, INCRBY ● Automatic increment by REDIS – To use automatic increment of redis we use INCR ● Example: – Set counter 1 incr counter // Output wil be 2 ● We can also use INCRBY – Set counter 1 – Incr counter – // Output wil be 2 – Incrby counter 10 – //outpur will be 12
  • 9. 9 DECR, DECRBY ● In opposite of INCR and INCRBY redis contains DESC and DESCBY – Just like DECR and DECRBY – Set counter 10 decr counter // Output wil be 9 decrby counter 5 //output will be 4
  • 10. 10 EXPIRE and TTL ● In REDIS we can set keys to expire in a given and specific amount of time. – To do that we use EXPIRE command – Example ● Set foo bar ● Expire foo 50 – To find out how many time a key have we use TTL command ● For instance after 10 second of declaring foo key if we use TTL command the output will be something like below: – Ttl foo //40
  • 11. 11 LISTS ● To create a list use LPUSH or RPUSH. If a list already exists, LPUSH will add the given value to the beginning of the list and RPUSH will add it to the end. ● Redis lists contain the following commands – SORT – RPUSH – LPUSH – LLEN – LTRIM – LRANGE – LPOP – RPOP – BLPOP – BRPOP –
  • 12. 12 LISTS redis 127.0.0.1:6379> lpush ages 10 (integer) 1 redis 127.0.0.1:6379> lpush ages 13 (integer) 2 redis 127.0.0.1:6379> lpush ages 12 (integer) 3 redis 127.0.0.1:6379> lpush ages 6 (integer) 4 redis 127.0.0.1:6379> LRANGE ages 0 3 1) "6" 2) "12" 3) "13" 4) "10" redis 127.0.0.1:6379> sort ages 1) "6" 2) "10" 3) "12" 4) "13" ----------------------------- redis 127.0.0.1:6379> lpop ages "6" redis 127.0.0.1:6379> rpop ages "10" redis 127.0.0.1:6379> LRANGE ages 0 10 1) "12" 2) "13" redis 127.0.0.1:6379>
  • 13. 13 SETS ● Sets are similar to lists but does not support duplication ● Example: – Add to sets ● redis 127.0.0.1:6379> SADD names "Michael" (integer) 1 redis 127.0.0.1:6379> SADD names "JOHN" (integer) 1 redis 127.0.0.1:6379> SMEMBERS names 1) "JOHN" 2) "Michael"
  • 14. 14 Lists ● Now, if you try to add another set member with JOHN value it will do nothing, because sets do not support duplication. ● Other useful commands for set – SADD, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SMEMBERS, SRANDMEMBER.
  • 15. 15 HASHES ● Using a hash, you can assign values to fields in each key. ● Common Commands in hashes are: – HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL
  • 16. 16 Example of HASHESredis 127.0.0.1:6379> hset student name "Ali" (integer) 1 redis 127.0.0.1:6379> hset student lastName "MasudianPour" (integer) 1 redis 127.0.0.1:6379> hset student number 101222 (integer) 1 redis 127.0.0.1:6379> hget student name "Ali" redis 127.0.0.1:6379> hget student lastName "MasudianPour" redis 127.0.0.1:6379> HGETALL student 1) "name" 2) "Ali" 3) "lastName" 4) "MasudianPour"
  • 17. 17 End ● This document is provided to be a little familiar with REDIS. I hope it help you to start working with REDIS.