SlideShare a Scribd company logo
1 of 20
Download to read offline
Redis - NoSQL DB
Redis

• In-memory persistant key-value store
• Asynchronous saving
• Written in ANSI-C
• 5 datatypes
• Atomic operations
!   !
!"#$%&'"()*%
    !   +"),)()&)-.-(//0"'12-&"32%1&%3"-!"!#$%&
        '(!)-4")#)
        !"3%21&'-$5)6-(//0"'"-%0)*%$"#'-.-7%"#%-)3"'-
        899-11'-,)0:%';-7%"#%-8999-&%,1*2)'-,1)-<*-
        #)&"'12-$/=%("#'-8-,)0:%-:*%>
    !   ?/)%*2"$"#'-.-*))"+'&#+,%&-#($+*,&./,";-
        &"#$%&'"6-,5),-,/&12-$))("&%&'-
        &"#$%&'1&=%',%&'>-@1)-&%0$%0-11%&')-,/)("-
        7"**"-7%"#%-A0"&=);-'%=",&%-&%##%-4")#)-"#1&%#-
        ,5)3%7%"#'-$"0),*%1
!                              !
!"#$%&""'%(%)"
              !   *$+,"-+,+.-/0")123"-
                  (+34"'-3"',"'%-#%04+-5+-
                  4"".-&632-*789
              !   :+34"'-3++1+.-!"#$;%-
                  0"4&"-<$"&234-5+-
                  "1+3#%1%-3++1+.-
                  5<2')+$%4



!         !
!"#$%&'()
    !   *+,-./0123!/453
        16/7'('88"8/$89"#:;
        */666/666/)9(<":/=>/012!/;:(?

        +@ABC@A
        D*E/666/(FB;"$/
    !   0G1+,-/H@IJ
        C@AK/L*66/666B;"$
        +@AK/LE6/666B;"$

!                              !
Datatypes

• Scalar (string, number)
• List (L)
• Set (S)
• Sorted Set (Z)
• Hash (H)
Scalar operations
• SET - set key value
• GET - get key value
• SETNX - set if not exists
• DEL - remove key
• INCR - increment by 1
• ...
Demo
!   "#$%&'('%)*+,'-%./"012
    )342

!   5#$%&'('
    )*+,'-%./"012

!   6#1%&'('
    789+

!   :.;*%<=>?-7?@?',
    A

!   :.;*%<=>?-7?@?',
    B

!   5#$%<=>?-7?@?',
    )B2
Expireing

• EXPIRE - seab võtme eluea sekundites
• TTL - sekundid eluea lõpuni
• PERSIST - eemaldab aegumise
Demo
!   "#$%&'('%)*+,'-%./"012
    )342

!   #CD:*#%&'('%AEE
    789+

!   $$1%&'('
    FG

!   D#*":"$%&'('
    789+

!   $$1%&'('
    HA
Lists

• List on sisuliselt sama, mis Array
  JavaScriptis.

  [elm1, elm2, elm3,.., elmN]
List operations
• RPUSH - lisa element listi lõppu
• LPUSH - lisa element listi algusesse
• LRANGE - tagasta vahemik elementidest
• LLEN - listi pikkus
• LREM - kustuta esimesed N elementi
• ...
Demo
!   1DI"J%K/7%)+H(?'>2
    A

!   1DI"J%K/7%)'>(?7??72
    B

!   *DI"J%K/7%)('&9%<?L?2
    M

!   11#.%K/7
    M

!   1*N.5#%K/7%A%B
    OP+H(?'>PQP('&9%<?L?PR

!   1*N.5#%K/7%E%HA
    OP'>(?7??7PQP+H(?'>PQP('&9%<?L?PR
Set

• Set on umbes sama nagu JavaScriptis Object
  - ainult et võtmetel pole väärtusi, võti kas
  on seatud või mitte (sisuliselt flags).

  {elm1:true, elm2:true, .., elmN:true}

  NB! igat võtit ainult 1 kord!
Set operations
• SADD - lisab võtme set’i
• SREM - eemaldab võtme
• SISMEMBER - kas võti on set’is
• SMEMBERS - tagastab kõik võtmed
• SUNION - liidab set’id kokku ja tagastab
• SDIFF - tagastab erinevused set’ide vahel
Demo
!   "N66%K/7%)+H(?'>2
    789+

!   "N66%K/7%)'>(?7??72
    789+

!   "N66%,+>S'%)+H(?'>2
    789+

!   "6:TT%K/7%,+>S'
    OP'>(?7??7PR

!   "U#UV#*"%K/7
    OP+H(?'>PQP'>(?7??7PR

!   "I.:3.%K/7%,+>S'
    OP+H(?'>PQP'>(?7??7PR
Sorted Set

• Sama nagu Set, aga igal võtmel on juures
  numbriline score, mille alusel on võtmed
  sorditud (võtmed on unikaalsed nagu Set
  puhul).

  {1234:”elm1”, 1235:”elm2, 1236:”elm3”,...}
Sorted Set operations
• ZADD - lisab võtme koos score’iga
• ZREM - eemaldab võtme
• ZRANK - tagastab indeksi (järjestatud score
   alusel)
• ZRANGEBYSCORE - tagastab vahemiku,
   kus score jääb min ja max vahele
• ....
Demo
!   WN66%-?',',%AAE%)K/72
    789+

!   WN66%-?',',%AAA%),+>S'2
    789+

!   W*N.5#%-?',',%E%HA
    OPK/7PQP,+>S'PR

!   W*#X*N.5#%-?',',%E%HA
    OP,+>S'PQPK/7PR

!   W";3*#%-?',',%)K/72
    )AAE2

!   W;N*6%-?',',
    B

More Related Content

What's hot

Selling Android Apps in 2010
Selling Android Apps in 2010Selling Android Apps in 2010
Selling Android Apps in 2010Kevin McDonagh
 
Escenari2013: Els Grups d'interès
Escenari2013: Els Grups d'interèsEscenari2013: Els Grups d'interès
Escenari2013: Els Grups d'interèsEntre2Mons
 
Summary of Product Offerings
Summary of Product OfferingsSummary of Product Offerings
Summary of Product Offeringstciesielka
 
Inbound aamiainen 14.6.2016
Inbound aamiainen 14.6.2016Inbound aamiainen 14.6.2016
Inbound aamiainen 14.6.2016Jani Aaltonen
 
“Não queremos instalar a ruptura no país” ps in público, 2015.03.22
“Não queremos instalar a ruptura no país”   ps in público, 2015.03.22“Não queremos instalar a ruptura no país”   ps in público, 2015.03.22
“Não queremos instalar a ruptura no país” ps in público, 2015.03.22FLUC
 
I Will Let You Into A Secret; Anyone Can Draw
I Will Let You Into A Secret; Anyone Can DrawI Will Let You Into A Secret; Anyone Can Draw
I Will Let You Into A Secret; Anyone Can DrawWonderlabs
 
Mediamplify Music and Mediamplify Platform
Mediamplify Music and Mediamplify PlatformMediamplify Music and Mediamplify Platform
Mediamplify Music and Mediamplify PlatformDr. Edwin Hernandez
 
Bizmaximum Flyer
Bizmaximum FlyerBizmaximum Flyer
Bizmaximum FlyerBIZMAXIMUM
 
Atom structure
Atom structureAtom structure
Atom structuresatapisat
 
Miasteczko Multimedialne
Miasteczko MultimedialneMiasteczko Multimedialne
Miasteczko Multimedialnecendoo1
 
Information Management Strategy from Business and IT Viewpoints
Information Management Strategy from Business and IT ViewpointsInformation Management Strategy from Business and IT Viewpoints
Information Management Strategy from Business and IT ViewpointsMarina Kerbel
 
Η ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 2 - ΕΙΣΑΓΩΓΗ ΣΤΙΣ ΚΛΑΣΕΙΣ (4 διαφ)
Η ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 2 - ΕΙΣΑΓΩΓΗ ΣΤΙΣ ΚΛΑΣΕΙΣ (4 διαφ)Η ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 2 - ΕΙΣΑΓΩΓΗ ΣΤΙΣ ΚΛΑΣΕΙΣ (4 διαφ)
Η ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 2 - ΕΙΣΑΓΩΓΗ ΣΤΙΣ ΚΛΑΣΕΙΣ (4 διαφ)Dimitris Psounis
 
3 prezentacja-aula polska5
3 prezentacja-aula polska53 prezentacja-aula polska5
3 prezentacja-aula polska5Marcin
 
Introduction to baysian_inference
Introduction to baysian_inferenceIntroduction to baysian_inference
Introduction to baysian_inferenceHiroki Iida
 
Modes of suspension
Modes of suspensionModes of suspension
Modes of suspensionMonika Löve
 

What's hot (20)

Selling Android Apps in 2010
Selling Android Apps in 2010Selling Android Apps in 2010
Selling Android Apps in 2010
 
Escenari2013: Els Grups d'interès
Escenari2013: Els Grups d'interèsEscenari2013: Els Grups d'interès
Escenari2013: Els Grups d'interès
 
Summary of Product Offerings
Summary of Product OfferingsSummary of Product Offerings
Summary of Product Offerings
 
Torseurs
TorseursTorseurs
Torseurs
 
Inbound aamiainen 14.6.2016
Inbound aamiainen 14.6.2016Inbound aamiainen 14.6.2016
Inbound aamiainen 14.6.2016
 
“Não queremos instalar a ruptura no país” ps in público, 2015.03.22
“Não queremos instalar a ruptura no país”   ps in público, 2015.03.22“Não queremos instalar a ruptura no país”   ps in público, 2015.03.22
“Não queremos instalar a ruptura no país” ps in público, 2015.03.22
 
I Will Let You Into A Secret; Anyone Can Draw
I Will Let You Into A Secret; Anyone Can DrawI Will Let You Into A Secret; Anyone Can Draw
I Will Let You Into A Secret; Anyone Can Draw
 
Mediamplify Music and Mediamplify Platform
Mediamplify Music and Mediamplify PlatformMediamplify Music and Mediamplify Platform
Mediamplify Music and Mediamplify Platform
 
Bizmaximum Flyer
Bizmaximum FlyerBizmaximum Flyer
Bizmaximum Flyer
 
Atom structure
Atom structureAtom structure
Atom structure
 
Miasteczko Multimedialne
Miasteczko MultimedialneMiasteczko Multimedialne
Miasteczko Multimedialne
 
Second Green Revolution_2012
Second Green Revolution_2012Second Green Revolution_2012
Second Green Revolution_2012
 
90 51
90 5190 51
90 51
 
Information Management Strategy from Business and IT Viewpoints
Information Management Strategy from Business and IT ViewpointsInformation Management Strategy from Business and IT Viewpoints
Information Management Strategy from Business and IT Viewpoints
 
Η ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 2 - ΕΙΣΑΓΩΓΗ ΣΤΙΣ ΚΛΑΣΕΙΣ (4 διαφ)
Η ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 2 - ΕΙΣΑΓΩΓΗ ΣΤΙΣ ΚΛΑΣΕΙΣ (4 διαφ)Η ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 2 - ΕΙΣΑΓΩΓΗ ΣΤΙΣ ΚΛΑΣΕΙΣ (4 διαφ)
Η ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 2 - ΕΙΣΑΓΩΓΗ ΣΤΙΣ ΚΛΑΣΕΙΣ (4 διαφ)
 
Carême saint laurent
Carême saint laurentCarême saint laurent
Carême saint laurent
 
3 prezentacja-aula polska5
3 prezentacja-aula polska53 prezentacja-aula polska5
3 prezentacja-aula polska5
 
Introduction to baysian_inference
Introduction to baysian_inferenceIntroduction to baysian_inference
Introduction to baysian_inference
 
Modes of suspension
Modes of suspensionModes of suspension
Modes of suspension
 
Tremmel J 201305
Tremmel J 201305Tremmel J 201305
Tremmel J 201305
 

Viewers also liked

Google App Engine ülevaade
Google App Engine ülevaadeGoogle App Engine ülevaade
Google App Engine ülevaadeAndris Reinman
 
Õpianalüütika töötuba
Õpianalüütika töötubaÕpianalüütika töötuba
Õpianalüütika töötubaKai Pata
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer ExperienceYuan Wang
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanPost Planner
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 

Viewers also liked (8)

Google App Engine ülevaade
Google App Engine ülevaadeGoogle App Engine ülevaade
Google App Engine ülevaade
 
Õpianalüütika töötuba
Õpianalüütika töötubaÕpianalüütika töötuba
Õpianalüütika töötuba
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Redis

  • 2. Redis • In-memory persistant key-value store • Asynchronous saving • Written in ANSI-C • 5 datatypes • Atomic operations
  • 3. ! !
  • 4. !"#$%&'"()*% ! +"),)()&)-.-(//0"'12-&"32%1&%3"-!"!#$%& '(!)-4")#) !"3%21&'-$5)6-(//0"'"-%0)*%$"#'-.-7%"#%-)3"'- 899-11'-,)0:%';-7%"#%-8999-&%,1*2)'-,1)-<*- #)&"'12-$/=%("#'-8-,)0:%-:*%> ! ?/)%*2"$"#'-.-*))"+'&#+,%&-#($+*,&./,";- &"#$%&'"6-,5),-,/&12-$))("&%&'- &"#$%&'1&=%',%&'>-@1)-&%0$%0-11%&')-,/)("- 7"**"-7%"#%-A0"&=);-'%=",&%-&%##%-4")#)-"#1&%#- ,5)3%7%"#'-$"0),*%1 ! !
  • 5. !"#$%&""'%(%)" ! *$+,"-+,+.-/0")123"- (+34"'-3"',"'%-#%04+-5+- 4"".-&632-*789 ! :+34"'-3++1+.-!"#$;%- 0"4&"-<$"&234-5+- "1+3#%1%-3++1+.- 5<2')+$%4 ! !
  • 6. !"#$%&'() ! *+,-./0123!/453 16/7'('88"8/$89"#:; */666/666/)9(<":/=>/012!/;:(? +@ABC@A D*E/666/(FB;"$/ ! 0G1+,-/H@IJ C@AK/L*66/666B;"$ +@AK/LE6/666B;"$ ! !
  • 7. Datatypes • Scalar (string, number) • List (L) • Set (S) • Sorted Set (Z) • Hash (H)
  • 8. Scalar operations • SET - set key value • GET - get key value • SETNX - set if not exists • DEL - remove key • INCR - increment by 1 • ...
  • 9. Demo ! "#$%&'('%)*+,'-%./"012 )342 ! 5#$%&'(' )*+,'-%./"012 ! 6#1%&'(' 789+ ! :.;*%<=>?-7?@?', A ! :.;*%<=>?-7?@?', B ! 5#$%<=>?-7?@?', )B2
  • 10. Expireing • EXPIRE - seab võtme eluea sekundites • TTL - sekundid eluea lõpuni • PERSIST - eemaldab aegumise
  • 11. Demo ! "#$%&'('%)*+,'-%./"012 )342 ! #CD:*#%&'('%AEE 789+ ! $$1%&'(' FG ! D#*":"$%&'(' 789+ ! $$1%&'(' HA
  • 12. Lists • List on sisuliselt sama, mis Array JavaScriptis. [elm1, elm2, elm3,.., elmN]
  • 13. List operations • RPUSH - lisa element listi lõppu • LPUSH - lisa element listi algusesse • LRANGE - tagasta vahemik elementidest • LLEN - listi pikkus • LREM - kustuta esimesed N elementi • ...
  • 14. Demo ! 1DI"J%K/7%)+H(?'>2 A ! 1DI"J%K/7%)'>(?7??72 B ! *DI"J%K/7%)('&9%<?L?2 M ! 11#.%K/7 M ! 1*N.5#%K/7%A%B OP+H(?'>PQP('&9%<?L?PR ! 1*N.5#%K/7%E%HA OP'>(?7??7PQP+H(?'>PQP('&9%<?L?PR
  • 15. Set • Set on umbes sama nagu JavaScriptis Object - ainult et võtmetel pole väärtusi, võti kas on seatud või mitte (sisuliselt flags). {elm1:true, elm2:true, .., elmN:true} NB! igat võtit ainult 1 kord!
  • 16. Set operations • SADD - lisab võtme set’i • SREM - eemaldab võtme • SISMEMBER - kas võti on set’is • SMEMBERS - tagastab kõik võtmed • SUNION - liidab set’id kokku ja tagastab • SDIFF - tagastab erinevused set’ide vahel
  • 17. Demo ! "N66%K/7%)+H(?'>2 789+ ! "N66%K/7%)'>(?7??72 789+ ! "N66%,+>S'%)+H(?'>2 789+ ! "6:TT%K/7%,+>S' OP'>(?7??7PR ! "U#UV#*"%K/7 OP+H(?'>PQP'>(?7??7PR ! "I.:3.%K/7%,+>S' OP+H(?'>PQP'>(?7??7PR
  • 18. Sorted Set • Sama nagu Set, aga igal võtmel on juures numbriline score, mille alusel on võtmed sorditud (võtmed on unikaalsed nagu Set puhul). {1234:”elm1”, 1235:”elm2, 1236:”elm3”,...}
  • 19. Sorted Set operations • ZADD - lisab võtme koos score’iga • ZREM - eemaldab võtme • ZRANK - tagastab indeksi (järjestatud score alusel) • ZRANGEBYSCORE - tagastab vahemiku, kus score jääb min ja max vahele • ....
  • 20. Demo ! WN66%-?',',%AAE%)K/72 789+ ! WN66%-?',',%AAA%),+>S'2 789+ ! W*N.5#%-?',',%E%HA OPK/7PQP,+>S'PR ! W*#X*N.5#%-?',',%E%HA OP,+>S'PQPK/7PR ! W";3*#%-?',',%)K/72 )AAE2 ! W;N*6%-?',', B