SlideShare a Scribd company logo
1 of 25
Download to read offline
&



    by Antonio De Patto ... a redis fan
Which one
Salvatore Sanfilippo
        aka
      antirez
ALL data-set in RAM
PERSIST
1) Periodic snapshot

2) In Append

3) Delegate to slave
Very fast




about 100.000 queries/second
5
 different
             ●   STRING
   data      ●   HASH
structures   ●   LIST

             ●   SETS

             ●   SORTED SETS
STRING
Simple string or integer values
STRING
Simple string or integer values




 GET Fetch the data stored at the given key

 SET Set the value stored at the given key

 DELETE Delete the value stored at the given key (works for all types)

 ex.

 SET users:anto "{'name': 'antonio', 'email':'anto80@gmail.com'}"
HASH
Unordered mapping of keys to values of strings or integer values
HASH
Unordered mapping of keys to values of strings or integer values



    HSET Stores the value at the key in the hash

    HGET Fetches the value at the given hash key

    HGETALL Fetches the entire hash

    HDEL Removes a key from the hash, if it exists

    ex.

    HSET users:1032 email anto80@gmail.com

    HSET users:searching anto80@gmail.com 1032
LIST
Ordered sequence of strings
LIST
Ordered sequence of strings


RPUSH Push the value onto the right end of the list

LRANGE Fetch a range of values from the list

LINDEX Fetch an item at a given position in the list

LPOP Pop the value from the left end of the list and return it

ex.

RPUSH zend:queue:log {'userId':12332,'UA':Opera/9.0 (Window....; en)'}
SET
Unordered bag of unique strings
SET
Unordered bag of unique strings



    SADD Add the item to the set

    SMEMBERS Return the entire set of items

    SISMEMBER Check if an item is in the set

    SREM Remove the item from the set, if it exists


    ex.

    SADD mycompany:myteam antonio giulio walter gianluca
SORTED SET (ZSET)
Ordered mapping of string members to floating point scores, ordered by score
SORTED SET (ZSET)
Ordered mapping of string members to floating point scores, ordered by score


   ZADD Add member with the given score to the ZSET

   ZRANGE Fetch the items in the ZSET from their positions in sorted order

   ZRANGEBYSCORE Fetch items in the ZSET based on a range of
   scores

   ZREM Remove the item from the ZSET, if it exists


   ex.

   ZADD game:users:1132 maxscore 2342
Redis to go?
        PhpRedis : https://github.com/nicolasff/phpredis




<?php

  $redis = new Redis();
  $redis->connect('127.0.0.1', 6379);
Sessions
session.save_handler = redis
session.save_path = "tcp://host1:6379?weight=1"
Cache
Queues




BLPOP, BRPOP, RPOPLPUSH
PUB/SUB

  PUBLISHER             PUBLISHER




              REDIS
  PUBLISHER             SUBSCRIBER
              pub/sub




  PUBLISHER             SUBSCRIBER
Php&redis presentation

More Related Content

What's hot

RedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative worksRedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative worksMd Shihab
 
Rust Mozlando Tutorial
Rust Mozlando TutorialRust Mozlando Tutorial
Rust Mozlando Tutorialnikomatsakis
 
Proxy OOP Pattern in PHP
Proxy OOP Pattern in PHPProxy OOP Pattern in PHP
Proxy OOP Pattern in PHPMarco Pivetta
 
Nouveau document texte
Nouveau document texteNouveau document texte
Nouveau document texteSai Ef
 
How to write rust instead of c and get away with it
How to write rust instead of c and get away with itHow to write rust instead of c and get away with it
How to write rust instead of c and get away with itFlavien Raynaud
 
Yy
YyYy
Yyyygh
 
Basic ASM by @binaryheadache
Basic ASM by @binaryheadacheBasic ASM by @binaryheadache
Basic ASM by @binaryheadachecamsec
 
Using the Power to Prove
Using the Power to ProveUsing the Power to Prove
Using the Power to ProveKazuho Oku
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)Lin Yo-An
 
The hidden and new parts of JS
The hidden and new parts of JSThe hidden and new parts of JS
The hidden and new parts of JSRitesh Kumar
 
Snakes for Camels
Snakes for CamelsSnakes for Camels
Snakes for Camelsmiquelruizm
 

What's hot (19)

RedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative worksRedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative works
 
C99
C99C99
C99
 
Perl basics for pentesters part 2
Perl basics for pentesters part 2Perl basics for pentesters part 2
Perl basics for pentesters part 2
 
Rust Mozlando Tutorial
Rust Mozlando TutorialRust Mozlando Tutorial
Rust Mozlando Tutorial
 
Proxy OOP Pattern in PHP
Proxy OOP Pattern in PHPProxy OOP Pattern in PHP
Proxy OOP Pattern in PHP
 
TDDBC お題
TDDBC お題TDDBC お題
TDDBC お題
 
Nouveau document texte
Nouveau document texteNouveau document texte
Nouveau document texte
 
How to write rust instead of c and get away with it
How to write rust instead of c and get away with itHow to write rust instead of c and get away with it
How to write rust instead of c and get away with it
 
Yy
YyYy
Yy
 
Lalal
LalalLalal
Lalal
 
Pig
PigPig
Pig
 
C99.php
C99.phpC99.php
C99.php
 
Basic ASM by @binaryheadache
Basic ASM by @binaryheadacheBasic ASM by @binaryheadache
Basic ASM by @binaryheadache
 
Using the Power to Prove
Using the Power to ProveUsing the Power to Prove
Using the Power to Prove
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
 
zinno
zinnozinno
zinno
 
The hidden and new parts of JS
The hidden and new parts of JSThe hidden and new parts of JS
The hidden and new parts of JS
 
Snakes for Camels
Snakes for CamelsSnakes for Camels
Snakes for Camels
 
Cod
CodCod
Cod
 

Viewers also liked

Ansewring g321 questions pp
Ansewring g321 questions ppAnsewring g321 questions pp
Ansewring g321 questions ppbankss
 
Ansewring g321 questions pp
Ansewring g321 questions ppAnsewring g321 questions pp
Ansewring g321 questions ppbankss
 
Visit to west park for arrugas project
Visit to west park for arrugas projectVisit to west park for arrugas project
Visit to west park for arrugas projectjpreston123
 
Archana G_Resume
Archana G_ResumeArchana G_Resume
Archana G_Resumearchu3011
 
Nosql storage in windows azure
Nosql storage in windows azureNosql storage in windows azure
Nosql storage in windows azureGal Kogman
 
High achievers growing beyond
High achievers   growing beyondHigh achievers   growing beyond
High achievers growing beyondYvonne Maier
 
Thinking big ernst_and_young_entrepreneurial_winning_women_think_big_impact_s...
Thinking big ernst_and_young_entrepreneurial_winning_women_think_big_impact_s...Thinking big ernst_and_young_entrepreneurial_winning_women_think_big_impact_s...
Thinking big ernst_and_young_entrepreneurial_winning_women_think_big_impact_s...Yvonne Maier
 
Do's & Dont's of making presentation
Do's & Dont's of making presentationDo's & Dont's of making presentation
Do's & Dont's of making presentationFakhar Hayat Sargana
 

Viewers also liked (11)

Ansewring g321 questions pp
Ansewring g321 questions ppAnsewring g321 questions pp
Ansewring g321 questions pp
 
Ansewring g321 questions pp
Ansewring g321 questions ppAnsewring g321 questions pp
Ansewring g321 questions pp
 
Visit to west park for arrugas project
Visit to west park for arrugas projectVisit to west park for arrugas project
Visit to west park for arrugas project
 
Archana G_Resume
Archana G_ResumeArchana G_Resume
Archana G_Resume
 
A Tour of Microsoft Azure
A Tour of Microsoft AzureA Tour of Microsoft Azure
A Tour of Microsoft Azure
 
Virus
VirusVirus
Virus
 
Virus
VirusVirus
Virus
 
Nosql storage in windows azure
Nosql storage in windows azureNosql storage in windows azure
Nosql storage in windows azure
 
High achievers growing beyond
High achievers   growing beyondHigh achievers   growing beyond
High achievers growing beyond
 
Thinking big ernst_and_young_entrepreneurial_winning_women_think_big_impact_s...
Thinking big ernst_and_young_entrepreneurial_winning_women_think_big_impact_s...Thinking big ernst_and_young_entrepreneurial_winning_women_think_big_impact_s...
Thinking big ernst_and_young_entrepreneurial_winning_women_think_big_impact_s...
 
Do's & Dont's of making presentation
Do's & Dont's of making presentationDo's & Dont's of making presentation
Do's & Dont's of making presentation
 

Similar to Php&redis presentation

Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redisTanu Siwag
 
Postgresql 9.3 overview
Postgresql 9.3 overviewPostgresql 9.3 overview
Postgresql 9.3 overviewAveic
 
Manipulating string data with a pattern in R
Manipulating string data with  a pattern in RManipulating string data with  a pattern in R
Manipulating string data with a pattern in RLun-Hsien Chang
 
A Divine Data Comedy
A Divine Data ComedyA Divine Data Comedy
A Divine Data ComedyMike Harris
 
Php7 hashtable
Php7 hashtablePhp7 hashtable
Php7 hashtable桐 王
 
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2aaronmorton
 
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2DataStax
 
The Ring programming language version 1.10 book - Part 45 of 212
The Ring programming language version 1.10 book - Part 45 of 212The Ring programming language version 1.10 book - Part 45 of 212
The Ring programming language version 1.10 book - Part 45 of 212Mahmoud Samir Fayed
 
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docxlab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docxDIPESH30
 
quickguide-einnovator-9-redis
quickguide-einnovator-9-redisquickguide-einnovator-9-redis
quickguide-einnovator-9-redisjorgesimao71
 
Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Dr. Volkan OBAN
 
Try Redis - interactive Tutorial
Try Redis - interactive TutorialTry Redis - interactive Tutorial
Try Redis - interactive TutorialEdward Lee
 
Introduction to R
Introduction to RIntroduction to R
Introduction to Ragnonchik
 

Similar to Php&redis presentation (20)

Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Intro to Redis
Intro to RedisIntro to Redis
Intro to Redis
 
Postgresql 9.3 overview
Postgresql 9.3 overviewPostgresql 9.3 overview
Postgresql 9.3 overview
 
Manipulating string data with a pattern in R
Manipulating string data with  a pattern in RManipulating string data with  a pattern in R
Manipulating string data with a pattern in R
 
Variables In Php 1
Variables In Php 1Variables In Php 1
Variables In Php 1
 
A Divine Data Comedy
A Divine Data ComedyA Divine Data Comedy
A Divine Data Comedy
 
php string part 3
php string part 3php string part 3
php string part 3
 
Php7 hashtable
Php7 hashtablePhp7 hashtable
Php7 hashtable
 
Redis Set Go
Redis Set GoRedis Set Go
Redis Set Go
 
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
 
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
The Ring programming language version 1.10 book - Part 45 of 212
The Ring programming language version 1.10 book - Part 45 of 212The Ring programming language version 1.10 book - Part 45 of 212
The Ring programming language version 1.10 book - Part 45 of 212
 
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docxlab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
 
Sql
SqlSql
Sql
 
quickguide-einnovator-9-redis
quickguide-einnovator-9-redisquickguide-einnovator-9-redis
quickguide-einnovator-9-redis
 
Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Rcommands-for those who interested in R.
Rcommands-for those who interested in R.
 
Python basic
Python basicPython basic
Python basic
 
Try Redis - interactive Tutorial
Try Redis - interactive TutorialTry Redis - interactive Tutorial
Try Redis - interactive Tutorial
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 

Php&redis presentation

  • 1. & by Antonio De Patto ... a redis fan
  • 3. Salvatore Sanfilippo aka antirez
  • 5. PERSIST 1) Periodic snapshot 2) In Append 3) Delegate to slave
  • 6.
  • 7. Very fast about 100.000 queries/second
  • 8. 5 different ● STRING data ● HASH structures ● LIST ● SETS ● SORTED SETS
  • 9. STRING Simple string or integer values
  • 10. STRING Simple string or integer values GET Fetch the data stored at the given key SET Set the value stored at the given key DELETE Delete the value stored at the given key (works for all types) ex. SET users:anto "{'name': 'antonio', 'email':'anto80@gmail.com'}"
  • 11. HASH Unordered mapping of keys to values of strings or integer values
  • 12. HASH Unordered mapping of keys to values of strings or integer values HSET Stores the value at the key in the hash HGET Fetches the value at the given hash key HGETALL Fetches the entire hash HDEL Removes a key from the hash, if it exists ex. HSET users:1032 email anto80@gmail.com HSET users:searching anto80@gmail.com 1032
  • 14. LIST Ordered sequence of strings RPUSH Push the value onto the right end of the list LRANGE Fetch a range of values from the list LINDEX Fetch an item at a given position in the list LPOP Pop the value from the left end of the list and return it ex. RPUSH zend:queue:log {'userId':12332,'UA':Opera/9.0 (Window....; en)'}
  • 15. SET Unordered bag of unique strings
  • 16. SET Unordered bag of unique strings SADD Add the item to the set SMEMBERS Return the entire set of items SISMEMBER Check if an item is in the set SREM Remove the item from the set, if it exists ex. SADD mycompany:myteam antonio giulio walter gianluca
  • 17. SORTED SET (ZSET) Ordered mapping of string members to floating point scores, ordered by score
  • 18. SORTED SET (ZSET) Ordered mapping of string members to floating point scores, ordered by score ZADD Add member with the given score to the ZSET ZRANGE Fetch the items in the ZSET from their positions in sorted order ZRANGEBYSCORE Fetch items in the ZSET based on a range of scores ZREM Remove the item from the ZSET, if it exists ex. ZADD game:users:1132 maxscore 2342
  • 19. Redis to go? PhpRedis : https://github.com/nicolasff/phpredis <?php $redis = new Redis(); $redis->connect('127.0.0.1', 6379);
  • 20.
  • 22. Cache
  • 24. PUB/SUB PUBLISHER PUBLISHER REDIS PUBLISHER SUBSCRIBER pub/sub PUBLISHER SUBSCRIBER