SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Presenter: Mubashar Iqbal
Software Engineer
Classical variant - store data in a relational database:
• MySQL
• PostgreSQL
• H2
• SQLite and many more...
Modern trend in a Web programming:
• Store data in NoSQL databases
Databases
• Non-relational database management system
• Did not expose the standard SQL interface
• Does not conform to ACID
• Working with a huge quantity of data
• Does not require a relational model
• Distributed, fault-tolerant architecture
NoSQL Introduction
Categories of NoSQL Databases

Key-Value
Memcached, Redis, Riak

Column Family
Cassandra, HBase

Document
MongoDB, CouchDB

Graph
Neo4j, InfoGrid
Redis

Redis means Remote Dictionary Server

Open Source

Key-Value Data store

Data structure server

In-Memory Dataset

Written in ANSI C and Sponsored by Pivotal.
http://redis.io/topics/introduction
Why and when you should use Redis?

Caching

Master-slave replication, automatic failover

High-IO workloads

Distributed Locks

Data that expires

Cookie storage

Analytics

Ad Targeting

Search engines

Small Data

Bigger Data

Forums
Who is using Redis?
http://redis.io/topics/whos-using-redis
Storing lots of Pinterest lists in Redis
Next time you log in to Pinterest, remember that Redis is
running in the background and storing several types of lists for
you as a user:

A list of users who you follow

A list of boards (and their related users) who you follow

A list of your followers

A list of people who follow your boards

A list of boards you follow

A list of boards you unfollowed after following a user

The followers and unfollowers of each board
Installation
Linux:
1. $ wget http://download.redis.io/releases/redis-2.8.9.tar.gz
2. $ tar xzf redis-2.8.9.tar.gz
3. $ cd redis-2.8.9
4. $ make
5. $ sudo make install
6. $ cd utils
7. $ sudo ./install_server.sh
Windows:
1. Download the latest .exe package from
http://github.com/MSOpenTech/redis
2. Running the exe will install Redis as a service and install
the Redis client.
Configuration
Redis is able to start without a configuration file using a
built-in default configuration.
The proper way to configure Redis is by providing a Redis
configuration file, usually called redis.conf.

Port: 6379

Timeout: 300

Maxclients 10000

Maxmemory <bytes>

Save 900 1
Running Redis Server and Client
Once the script completes, the redis-server will be running
in the background.
You can start and stop redis with these commands.
sudo service redis_6379 start
sudo service redis_6379 stop
Access the redis database by typing the following
command.
redis-cli
Redis Clients

Phpredis – Redis client written in C for PHP.

Redis-py – Mature Redis client for Python.

Redis-rb – Very stable & Muture Client for Rubys

Scala-redis – Mature Redis client for Scala

Node_redis – Recommended client for node.

Jedis – Java client library for Redis.

Eredis – A Redis erlang client library.
Example Code
Write a simple php script to test redis php client:
<?php
$redis=new Redis() or die("Can't load redis client.");
$redis->connect('127.0.0.1', 6379);
$redis->set('set_testkey', 1);
?>
Parameters:
Host: string. can be a host, or the path to a unix domain socket
Port: int, optional
Return value:
BOOL: TRUE on success, FALSE on error.
Redis Data Types
Redis is often referred to as a data structure server since
keys can contain:

Strings

Lists

Sets

Hashes

Sorted Sets
http://redis.io/topics/data-types
Strings

Most basic kind of Redis value

Binary safe - can contain any kind of data

Max 512 Megabytes in length

Can be used as atomic counters using commands in the
INCR family
APPEND – Append a value to a key
GET – Get the value of a key
SET – Set the string value of a key
MGET – Get the values of all the given keys
MSET – Set multiple keys to multiple values
Lists

Lists of strings, sorted by insertion order

Add elements to a Redis List pushing new elements on the
head (on the left) or on the tail (on the right) of the list
LSET – Set the value of an element in a list by its index
LLEN – Get the length of a list
LREM – Remove elements from a list
LINSERT – Insert an element before or after another
element in a list
LRANGE – Get a range of elements from a list
LPOP – Remove and get the first element in a list
RPOP – Remove and get the last element in a list
Sets

Redis Sets are an unordered collection of Strings.

You can track unique things using Redis Sets.
SADD – Add one or more members to a set
SISMEMBER – Determine if a given value is a member of a set
SMEMBERS – Get all the members in a set
SPOP – Remove and return a random member from a set
SRANDMEMBER – Get one or multiple random members from a
set
SREM – Remove one or more members from a set
Hashes

Map between string fields and string values

Every hash can store more than 4 billion field-value pairs.
HSET – Set the string value of a hash field
HGET – Get the value of a hash field
HMGET – Get the values of all the given hash fields
HMSET – Set multiple hash fields to multiple values
HLEN – Get the number of fields in a hash
HKEYS – Get all the fields in a hash
HGETALL – Get all the fields and values in a hash
Sorted Sets

Every member of a Sorted Set is associated with score,
that is used in order to take the sorted set ordered, from
the smallest to the greatest score

You can do a lot of tasks with great performance that are
really hard to model in other kind of databases

Probably the most advanced Redis data type
ZADD – Add one or more members to a sorted set, or update its
score if it already exists
ZREM – Remove one or more members from a sorted set
ZRANGE – Return a range of members in a sorted set, by index
ZINCRBY – Increment the score of a member in a sorted set
Replication
Master-slave replication that allows slave Redis servers to
be exact copies of master servers.

A master can have multiple slaves.

Slaves are able to accept connections from other slaves.

Replication can be used both for scalability and for data
redundancy.

Slave instance facility for scaling out read requests or
mitigate a disaster recovery scenario.
Setup the Master Server
To configure replication is very simple just add the following
line to the slave configuration file:
slaveof 192.168.1.1 6379
Replace 192.168.1.1 6379 with your master IP address and
port.
Replication only needs to be defined on Slave systems, the
Master server does not require any special configuration.
Performance
Popularity of Redis:

Speed

Rich semantics

Stability

Durability / Persistence
- Redis snapshots
- Append-only file (AOF)
Comparison
Resources
1. http://www.redis.io
2. http://bencane.com/2013/11/12/installing-redis-
and-setting-up-master-slave-replication/
3. http://oldblog.antirez.com/post/redis-memcached-
benchmark.html
4. http://oldblog.antirez.com/post/update-on-
memcached-redis-benchmark.html
5. http://blog.gopivotal.com/pivotal/case-studies-
2/using-redis-at-pinterest-for-billions-of-relationships
Redis NoSQL (Key-value) Database

Weitere ähnliche Inhalte

Andere mochten auch

PostgreSQL: вчера, сегодня, завтра, Олег Бартунов, Postgres Professional, Мо...
 PostgreSQL: вчера, сегодня, завтра, Олег Бартунов, Postgres Professional, Мо... PostgreSQL: вчера, сегодня, завтра, Олег Бартунов, Postgres Professional, Мо...
PostgreSQL: вчера, сегодня, завтра, Олег Бартунов, Postgres Professional, Мо...it-people
 
Geek Academy Week 3 :: Redis for developer
Geek Academy Week 3 :: Redis for developerGeek Academy Week 3 :: Redis for developer
Geek Academy Week 3 :: Redis for developerSomkiat Puisungnoen
 
TechLeads meetup: Евгений Потапов, ITSumma
TechLeads meetup: Евгений Потапов, ITSumma TechLeads meetup: Евгений Потапов, ITSumma
TechLeads meetup: Евгений Потапов, ITSumma Badoo Development
 
TechLeads meetup: Макс Лапшин, Erlyvideo
TechLeads meetup: Макс Лапшин, ErlyvideoTechLeads meetup: Макс Лапшин, Erlyvideo
TechLeads meetup: Макс Лапшин, ErlyvideoBadoo Development
 
TechLeads meetup: Алексей Рыбак, Badoo
TechLeads meetup: Алексей Рыбак, BadooTechLeads meetup: Алексей Рыбак, Badoo
TechLeads meetup: Алексей Рыбак, BadooBadoo Development
 
TechLeads meetup: Андрей Шелёхин, Tinkoff.ru
TechLeads meetup: Андрей Шелёхин, Tinkoff.ruTechLeads meetup: Андрей Шелёхин, Tinkoff.ru
TechLeads meetup: Андрей Шелёхин, Tinkoff.ruBadoo Development
 

Andere mochten auch (6)

PostgreSQL: вчера, сегодня, завтра, Олег Бартунов, Postgres Professional, Мо...
 PostgreSQL: вчера, сегодня, завтра, Олег Бартунов, Postgres Professional, Мо... PostgreSQL: вчера, сегодня, завтра, Олег Бартунов, Postgres Professional, Мо...
PostgreSQL: вчера, сегодня, завтра, Олег Бартунов, Postgres Professional, Мо...
 
Geek Academy Week 3 :: Redis for developer
Geek Academy Week 3 :: Redis for developerGeek Academy Week 3 :: Redis for developer
Geek Academy Week 3 :: Redis for developer
 
TechLeads meetup: Евгений Потапов, ITSumma
TechLeads meetup: Евгений Потапов, ITSumma TechLeads meetup: Евгений Потапов, ITSumma
TechLeads meetup: Евгений Потапов, ITSumma
 
TechLeads meetup: Макс Лапшин, Erlyvideo
TechLeads meetup: Макс Лапшин, ErlyvideoTechLeads meetup: Макс Лапшин, Erlyvideo
TechLeads meetup: Макс Лапшин, Erlyvideo
 
TechLeads meetup: Алексей Рыбак, Badoo
TechLeads meetup: Алексей Рыбак, BadooTechLeads meetup: Алексей Рыбак, Badoo
TechLeads meetup: Алексей Рыбак, Badoo
 
TechLeads meetup: Андрей Шелёхин, Tinkoff.ru
TechLeads meetup: Андрей Шелёхин, Tinkoff.ruTechLeads meetup: Андрей Шелёхин, Tinkoff.ru
TechLeads meetup: Андрей Шелёхин, Tinkoff.ru
 

Kürzlich hochgeladen

Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 

Kürzlich hochgeladen (20)

Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 

Redis NoSQL (Key-value) Database

  • 2. Classical variant - store data in a relational database: • MySQL • PostgreSQL • H2 • SQLite and many more... Modern trend in a Web programming: • Store data in NoSQL databases Databases
  • 3. • Non-relational database management system • Did not expose the standard SQL interface • Does not conform to ACID • Working with a huge quantity of data • Does not require a relational model • Distributed, fault-tolerant architecture NoSQL Introduction
  • 4. Categories of NoSQL Databases  Key-Value Memcached, Redis, Riak  Column Family Cassandra, HBase  Document MongoDB, CouchDB  Graph Neo4j, InfoGrid
  • 5. Redis  Redis means Remote Dictionary Server  Open Source  Key-Value Data store  Data structure server  In-Memory Dataset  Written in ANSI C and Sponsored by Pivotal. http://redis.io/topics/introduction
  • 6. Why and when you should use Redis?  Caching  Master-slave replication, automatic failover  High-IO workloads  Distributed Locks  Data that expires  Cookie storage  Analytics  Ad Targeting  Search engines  Small Data  Bigger Data  Forums
  • 7. Who is using Redis? http://redis.io/topics/whos-using-redis
  • 8. Storing lots of Pinterest lists in Redis Next time you log in to Pinterest, remember that Redis is running in the background and storing several types of lists for you as a user:  A list of users who you follow  A list of boards (and their related users) who you follow  A list of your followers  A list of people who follow your boards  A list of boards you follow  A list of boards you unfollowed after following a user  The followers and unfollowers of each board
  • 9. Installation Linux: 1. $ wget http://download.redis.io/releases/redis-2.8.9.tar.gz 2. $ tar xzf redis-2.8.9.tar.gz 3. $ cd redis-2.8.9 4. $ make 5. $ sudo make install 6. $ cd utils 7. $ sudo ./install_server.sh Windows: 1. Download the latest .exe package from http://github.com/MSOpenTech/redis 2. Running the exe will install Redis as a service and install the Redis client.
  • 10. Configuration Redis is able to start without a configuration file using a built-in default configuration. The proper way to configure Redis is by providing a Redis configuration file, usually called redis.conf.  Port: 6379  Timeout: 300  Maxclients 10000  Maxmemory <bytes>  Save 900 1
  • 11. Running Redis Server and Client Once the script completes, the redis-server will be running in the background. You can start and stop redis with these commands. sudo service redis_6379 start sudo service redis_6379 stop Access the redis database by typing the following command. redis-cli
  • 12. Redis Clients  Phpredis – Redis client written in C for PHP.  Redis-py – Mature Redis client for Python.  Redis-rb – Very stable & Muture Client for Rubys  Scala-redis – Mature Redis client for Scala  Node_redis – Recommended client for node.  Jedis – Java client library for Redis.  Eredis – A Redis erlang client library.
  • 13. Example Code Write a simple php script to test redis php client: <?php $redis=new Redis() or die("Can't load redis client."); $redis->connect('127.0.0.1', 6379); $redis->set('set_testkey', 1); ?> Parameters: Host: string. can be a host, or the path to a unix domain socket Port: int, optional Return value: BOOL: TRUE on success, FALSE on error.
  • 14. Redis Data Types Redis is often referred to as a data structure server since keys can contain:  Strings  Lists  Sets  Hashes  Sorted Sets http://redis.io/topics/data-types
  • 15. Strings  Most basic kind of Redis value  Binary safe - can contain any kind of data  Max 512 Megabytes in length  Can be used as atomic counters using commands in the INCR family APPEND – Append a value to a key GET – Get the value of a key SET – Set the string value of a key MGET – Get the values of all the given keys MSET – Set multiple keys to multiple values
  • 16. Lists  Lists of strings, sorted by insertion order  Add elements to a Redis List pushing new elements on the head (on the left) or on the tail (on the right) of the list LSET – Set the value of an element in a list by its index LLEN – Get the length of a list LREM – Remove elements from a list LINSERT – Insert an element before or after another element in a list LRANGE – Get a range of elements from a list LPOP – Remove and get the first element in a list RPOP – Remove and get the last element in a list
  • 17. Sets  Redis Sets are an unordered collection of Strings.  You can track unique things using Redis Sets. SADD – Add one or more members to a set SISMEMBER – Determine if a given value is a member of a set SMEMBERS – Get all the members in a set SPOP – Remove and return a random member from a set SRANDMEMBER – Get one or multiple random members from a set SREM – Remove one or more members from a set
  • 18. Hashes  Map between string fields and string values  Every hash can store more than 4 billion field-value pairs. HSET – Set the string value of a hash field HGET – Get the value of a hash field HMGET – Get the values of all the given hash fields HMSET – Set multiple hash fields to multiple values HLEN – Get the number of fields in a hash HKEYS – Get all the fields in a hash HGETALL – Get all the fields and values in a hash
  • 19. Sorted Sets  Every member of a Sorted Set is associated with score, that is used in order to take the sorted set ordered, from the smallest to the greatest score  You can do a lot of tasks with great performance that are really hard to model in other kind of databases  Probably the most advanced Redis data type ZADD – Add one or more members to a sorted set, or update its score if it already exists ZREM – Remove one or more members from a sorted set ZRANGE – Return a range of members in a sorted set, by index ZINCRBY – Increment the score of a member in a sorted set
  • 20. Replication Master-slave replication that allows slave Redis servers to be exact copies of master servers.  A master can have multiple slaves.  Slaves are able to accept connections from other slaves.  Replication can be used both for scalability and for data redundancy.  Slave instance facility for scaling out read requests or mitigate a disaster recovery scenario.
  • 21. Setup the Master Server To configure replication is very simple just add the following line to the slave configuration file: slaveof 192.168.1.1 6379 Replace 192.168.1.1 6379 with your master IP address and port. Replication only needs to be defined on Slave systems, the Master server does not require any special configuration.
  • 22. Performance Popularity of Redis:  Speed  Rich semantics  Stability  Durability / Persistence - Redis snapshots - Append-only file (AOF)
  • 24. Resources 1. http://www.redis.io 2. http://bencane.com/2013/11/12/installing-redis- and-setting-up-master-slave-replication/ 3. http://oldblog.antirez.com/post/redis-memcached- benchmark.html 4. http://oldblog.antirez.com/post/update-on- memcached-redis-benchmark.html 5. http://blog.gopivotal.com/pivotal/case-studies- 2/using-redis-at-pinterest-for-billions-of-relationships