SlideShare ist ein Scribd-Unternehmen logo
1 von 10
A Simple Introduction to Redis
                   Zhichao Liang
         frankey0207@gmail.com
What’s Redis?
• Redis is an open source, 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 is written in ANSI C and works in most POSIX
  systems like Linux, *BSD, OS X and Solaris without
  external dependencies.
• Redis can be used from most programming
  languages, such as C, C#, C++, Java, Lua, Node.js, Perl,
  Objective-C, PHP, Python, Ruby, Smalltalk, Scala,
  Erlang, Common Lisp …
How to use Redis?
• We can download the source code of Redis from
  http://redis.io/download and install it just by make
  && make install.
• By default, both the server and client of Redis can be
  found in the directory /usr/local/bin after installation.
• Some common commands:
  - set/get/mset/mget
  - lpush/rpush/lpop/rpop
  - hset/hget/hmset/hmget
  - sadd/smembers/zadd/zrange
C Client
• Hiredis is a official C client library for the Redis
  database.
• We can download Hiredis from
  https://github.com/antirez/hiredis/downloads.
   redisContext *c = redisConnect("127.0.0.1", 6379);
   if (c->err) {
            printf("Error: %sn", c->errstr);
   }
   reply = redisCommand(redisContext , "SET foo bar");
Java Client
• Jedis is a blazingly small and sane Redis java client.
• We can download Jedis package from
  https://github.com/xetorthio/jedis/downloads.
   Jedis jedis = new Jedis("localhost");
   jedis.connect();
   jedis.set("foo", "bar");
   String value = jedis.get("foo");
Redis Persistence
• Redis provides a different range of persistence
  options: RDB and AOF.
• The RDB persistence performs point-in-time
  snapshots of your dataset at specified intervals.
  - #save 900 1 or #save 300 10
• The AOF persistence logs every write operation
  received by the server, that will be played again at
  server startup, reconstructing the original dataset.
  - no fsync at all or fsync every second or fsync at
  every query
Redis Replication
• Redis master-slave replication allows slave Redis
  servers to be exact copies of master.
  - A master can have multiple
  slaves                                         slave
  -Slaves can accept other
  slaves connections
                                   master
  - Non-blocking at the master
  side
                                                 slave
  - Replication can be used for
  scalability
  - Replication can avoid saving
  process at master side
Redis Cluster
• Redis nodes are connected and functionally
  equivalent, but actually there are two kinds of nodes:
  master nodes and slave nodes.
                                               1
                                  0                4
                                       2       3
         1
                  3               5
          4                           master       0
                      slave                                2

     0                                                 5
              2
                                  1
      5                       4
                                  3
Redis Replication
Who’s using Redis?
 • Redis has been widely used in microblog service
redis> hset yaochen follows 547
(integer) 1 by Sina Weibo.
    provied
redis> hset yaochen fans 17647778
(integer) 1
redis> hset yaochen microblogs
5359
(integer) 1
redis> hgetall yaochen
1) “follows"
2) “547"
3) "fans"
4) “17647778"
5) "microblogs"
6) “5359"

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Dvir Volk
 

Was ist angesagt? (20)

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
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
 
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
 
Redis and it's data types
Redis and it's data typesRedis and it's data types
Redis and it's data types
 
Redis database
Redis databaseRedis database
Redis database
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Redis overview
Redis overviewRedis overview
Redis overview
 
Redis 101
Redis 101Redis 101
Redis 101
 
Paris Redis Meetup Introduction
Paris Redis Meetup IntroductionParis Redis Meetup Introduction
Paris Redis Meetup Introduction
 
Redis Persistence
Redis  PersistenceRedis  Persistence
Redis Persistence
 
Redis Overview
Redis OverviewRedis Overview
Redis Overview
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
 
Troubleshooting redis
Troubleshooting redisTroubleshooting redis
Troubleshooting redis
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examples
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Federated Engine 실무적용사례
Federated Engine 실무적용사례Federated Engine 실무적용사례
Federated Engine 실무적용사례
 

Ähnlich wie A simple introduction to redis

Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
Ricard Clau
 
Use case for using the ElastiCache for Redis in production
Use case for using the ElastiCache for Redis in productionUse case for using the ElastiCache for Redis in production
Use case for using the ElastiCache for Redis in production
知教 本間
 

Ähnlich wie A simple introduction to redis (20)

REDIS327
REDIS327REDIS327
REDIS327
 
Redis
RedisRedis
Redis
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
 
Fun with Ruby and Redis
Fun with Ruby and RedisFun with Ruby and Redis
Fun with Ruby and Redis
 
Redis meetup
Redis meetupRedis meetup
Redis meetup
 
Redis - The Universal NoSQL Tool
Redis - The Universal NoSQL ToolRedis - The Universal NoSQL Tool
Redis - The Universal NoSQL Tool
 
Redis in a Multi Tenant Environment–High Availability, Monitoring & Much More!
Redis in a Multi Tenant Environment–High Availability, Monitoring & Much More! Redis in a Multi Tenant Environment–High Availability, Monitoring & Much More!
Redis in a Multi Tenant Environment–High Availability, Monitoring & Much More!
 
Redis High availability and fault tolerance in a multitenant environment
Redis High availability and fault tolerance in a multitenant environmentRedis High availability and fault tolerance in a multitenant environment
Redis High availability and fault tolerance in a multitenant environment
 
Redis acc 2015_eng
Redis acc 2015_engRedis acc 2015_eng
Redis acc 2015_eng
 
Private DNS
Private DNSPrivate DNS
Private DNS
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
 
LINSTOR - Resilient OSS Storage for OpenNebula - September 2018
LINSTOR - Resilient OSS Storage for OpenNebula - September 2018LINSTOR - Resilient OSS Storage for OpenNebula - September 2018
LINSTOR - Resilient OSS Storage for OpenNebula - September 2018
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
 
Use case for using the ElastiCache for Redis in production
Use case for using the ElastiCache for Redis in productionUse case for using the ElastiCache for Redis in production
Use case for using the ElastiCache for Redis in production
 
KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
 
Redis ndc2013
Redis ndc2013Redis ndc2013
Redis ndc2013
 
Big Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and MesosBig Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and Mesos
 
Rootless Containers
Rootless ContainersRootless Containers
Rootless Containers
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 

Mehr von Zhichao Liang

A novel method to extend flash memory lifetime in flash based dbms
A novel method to extend flash memory lifetime in flash based dbmsA novel method to extend flash memory lifetime in flash based dbms
A novel method to extend flash memory lifetime in flash based dbms
Zhichao Liang
 

Mehr von Zhichao Liang (14)

微软Bot framework简介
微软Bot framework简介微软Bot framework简介
微软Bot framework简介
 
青云虚拟机部署私有Docker Registry
青云虚拟机部署私有Docker Registry青云虚拟机部署私有Docker Registry
青云虚拟机部署私有Docker Registry
 
开源Pass平台flynn功能简介
开源Pass平台flynn功能简介开源Pass平台flynn功能简介
开源Pass平台flynn功能简介
 
青云CoreOS虚拟机部署kubernetes
青云CoreOS虚拟机部署kubernetes 青云CoreOS虚拟机部署kubernetes
青云CoreOS虚拟机部署kubernetes
 
Introduction of own cloud
Introduction of own cloudIntroduction of own cloud
Introduction of own cloud
 
Power drill列存储底层设计
Power drill列存储底层设计Power drill列存储底层设计
Power drill列存储底层设计
 
C store底层存储设计
C store底层存储设计C store底层存储设计
C store底层存储设计
 
Storage Class Memory: Technology Overview & System Impacts
Storage Class Memory: Technology Overview & System ImpactsStorage Class Memory: Technology Overview & System Impacts
Storage Class Memory: Technology Overview & System Impacts
 
Memcached简介
Memcached简介Memcached简介
Memcached简介
 
Some key value stores using log-structure
Some key value stores using log-structureSome key value stores using log-structure
Some key value stores using log-structure
 
A novel method to extend flash memory lifetime in flash based dbms
A novel method to extend flash memory lifetime in flash based dbmsA novel method to extend flash memory lifetime in flash based dbms
A novel method to extend flash memory lifetime in flash based dbms
 
Sub join a query optimization algorithm for flash-based database
Sub join a query optimization algorithm for flash-based databaseSub join a query optimization algorithm for flash-based database
Sub join a query optimization algorithm for flash-based database
 
Hush…tell you something novel about flash memory
Hush…tell you something novel about flash memoryHush…tell you something novel about flash memory
Hush…tell you something novel about flash memory
 
Survey of distributed storage system
Survey of distributed storage systemSurvey of distributed storage system
Survey of distributed storage system
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 

A simple introduction to redis

  • 1. A Simple Introduction to Redis Zhichao Liang frankey0207@gmail.com
  • 2. What’s Redis? • Redis is an open source, 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 is written in ANSI C and works in most POSIX systems like Linux, *BSD, OS X and Solaris without external dependencies. • Redis can be used from most programming languages, such as C, C#, C++, Java, Lua, Node.js, Perl, Objective-C, PHP, Python, Ruby, Smalltalk, Scala, Erlang, Common Lisp …
  • 3. How to use Redis? • We can download the source code of Redis from http://redis.io/download and install it just by make && make install. • By default, both the server and client of Redis can be found in the directory /usr/local/bin after installation. • Some common commands: - set/get/mset/mget - lpush/rpush/lpop/rpop - hset/hget/hmset/hmget - sadd/smembers/zadd/zrange
  • 4. C Client • Hiredis is a official C client library for the Redis database. • We can download Hiredis from https://github.com/antirez/hiredis/downloads. redisContext *c = redisConnect("127.0.0.1", 6379); if (c->err) { printf("Error: %sn", c->errstr); } reply = redisCommand(redisContext , "SET foo bar");
  • 5. Java Client • Jedis is a blazingly small and sane Redis java client. • We can download Jedis package from https://github.com/xetorthio/jedis/downloads. Jedis jedis = new Jedis("localhost"); jedis.connect(); jedis.set("foo", "bar"); String value = jedis.get("foo");
  • 6. Redis Persistence • Redis provides a different range of persistence options: RDB and AOF. • The RDB persistence performs point-in-time snapshots of your dataset at specified intervals. - #save 900 1 or #save 300 10 • The AOF persistence logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset. - no fsync at all or fsync every second or fsync at every query
  • 7. Redis Replication • Redis master-slave replication allows slave Redis servers to be exact copies of master. - A master can have multiple slaves slave -Slaves can accept other slaves connections master - Non-blocking at the master side slave - Replication can be used for scalability - Replication can avoid saving process at master side
  • 8. Redis Cluster • Redis nodes are connected and functionally equivalent, but actually there are two kinds of nodes: master nodes and slave nodes. 1 0 4 2 3 1 3 5 4 master 0 slave 2 0 5 2 1 5 4 3
  • 10. Who’s using Redis? • Redis has been widely used in microblog service redis> hset yaochen follows 547 (integer) 1 by Sina Weibo. provied redis> hset yaochen fans 17647778 (integer) 1 redis> hset yaochen microblogs 5359 (integer) 1 redis> hgetall yaochen 1) “follows" 2) “547" 3) "fans" 4) “17647778" 5) "microblogs" 6) “5359"