SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
REDIS:
INSTALLATION,
CONFIGURATION &
IMPLEMENTATION
Everything and Anything I.T
By
Abhijeet Shekhar
Installation
Linux: http://redis.io/download
Windows
1. Clone from Git repo:
https://github.com/MSOpenTech/redis
2. Unzip file from /redis/bin/release
(e.g. redisbin64.zip) to /redis
3. Important files:
 /redis/redis-server.exe
 /redis/redis-cli.exe
Configuration
 Configuration file: /redis/redis.conf
 It is possible to change a port (if you wish):
 For development environment it is useful to
change data persisting policy
port 6379
save 900 1
save 300 10
save 60 10000
save 10 1
save after 10 sec if at least 1 key changed
Running Redis Server
 Run /redis/bin/redis-server.exe and
specify configuration file to use
redis>redis-server redis.conf
Running Redis Client
 Run /redis/bin/redis-cli.exe
 Now you can play with Redis a little bit
Useful Commands
 Print all keys:
 Remove all keys from all databases
 Synchronously save the dataset to disk
KEYS *
FLUSHALL
SAVE
Redis keys
 Keys are binary safe - it is possible to use any
binary sequence as a key
 The empty string is also a valid key
 Too long keys are not a good idea
 Too short keys are often also not a good idea
("u:1000:pwd" versus "user:1000:password")
 Nice idea is to use some kind of schema, like:
"object-type:id:field"
Redis data types
Redis is often referred to as a data structure
server since keys can contain:
 Strings
 Lists
 Sets
 Hashes
 Sorted Sets
Redis Strings: Example
Redis 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
 Max length: (2^32 - 1) elements
 Model a timeline in a social network, using LPUSH
to add new elements, and using LRANGE in order
to retrieve recent items
 Use LPUSH together with LTRIM to create a list
that never exceeds a given number of elements
Redis Lists: Example
Redis 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
Redis Hashes
 Map between string fields and string values
 Perfect data type to represent objects
HMSET user:1000 username abhi password 123 age 28
HGETALL user:1000
HSET user:1000 password 12345
HGETALL user:1000
Redis Operations
It is possible to run atomic operations on data
types:
 appending to a string
 incrementing the value in a hash
 pushing to a list
 computing set intersection, union and difference
 getting the member with highest ranking in a
sorted set
Redis client
 PHPRedis – PHP Client for Redis
(https://github.com/nicolasff/phpredis)
 JRedis - Java Client for Redis
 Jedis - a blazingly small and sane Redis Java client
 Spring Data Redis
Configuration
By Redis.conf
port 6379
bind 127.0.0.1
maxclients 10000
maxmemory <bytes>
By script
$redis->config("GET", "*max-*-entries*");
$redis->config("SET", "dir",
"/var/run/redis/dumps/");
PHP code
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->set('key','value', 10); // Will set the key, if it
doesn't exist, with a ttl of 10 seconds
echo $redis->get(‘key’);
?>
Thanks 

Mais conteúdo relacionado

Semelhante a Redis Installation Configuration And Implementation

quickguide-einnovator-9-redis
quickguide-einnovator-9-redisquickguide-einnovator-9-redis
quickguide-einnovator-9-redis
jorgesimao71
 
Work Stealing For Fun & Profit: Jim Nelson
Work Stealing For Fun & Profit: Jim NelsonWork Stealing For Fun & Profit: Jim Nelson
Work Stealing For Fun & Profit: Jim Nelson
Redis Labs
 
Linux admin interview questions
Linux admin interview questionsLinux admin interview questions
Linux admin interview questions
Kavya Sri
 

Semelhante a Redis Installation Configuration And Implementation (20)

quickguide-einnovator-9-redis
quickguide-einnovator-9-redisquickguide-einnovator-9-redis
quickguide-einnovator-9-redis
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Redispresentation apac2012
Redispresentation apac2012Redispresentation apac2012
Redispresentation apac2012
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Fun with Ruby and Redis
Fun with Ruby and RedisFun with Ruby and Redis
Fun with Ruby and Redis
 
Redis
RedisRedis
Redis
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
Redis introduction
Redis introductionRedis introduction
Redis introduction
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
Redis overview
Redis overviewRedis overview
Redis overview
 
Work Stealing For Fun & Profit: Jim Nelson
Work Stealing For Fun & Profit: Jim NelsonWork Stealing For Fun & Profit: Jim Nelson
Work Stealing For Fun & Profit: Jim Nelson
 
Red Hat Certified engineer course
  Red Hat Certified engineer course   Red Hat Certified engineer course
Red Hat Certified engineer course
 
Linux_Commands_MT.pdf
Linux_Commands_MT.pdfLinux_Commands_MT.pdf
Linux_Commands_MT.pdf
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Redis. Seattle Data Science and Data Engineering Meetup
Redis. Seattle Data Science and Data Engineering MeetupRedis. Seattle Data Science and Data Engineering Meetup
Redis. Seattle Data Science and Data Engineering Meetup
 
Redis basics
Redis basicsRedis basics
Redis basics
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Linux admin interview questions
Linux admin interview questionsLinux admin interview questions
Linux admin interview questions
 
Linux basic
Linux basicLinux basic
Linux basic
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 

Redis Installation Configuration And Implementation

  • 2. Installation Linux: http://redis.io/download Windows 1. Clone from Git repo: https://github.com/MSOpenTech/redis 2. Unzip file from /redis/bin/release (e.g. redisbin64.zip) to /redis 3. Important files:  /redis/redis-server.exe  /redis/redis-cli.exe
  • 3. Configuration  Configuration file: /redis/redis.conf  It is possible to change a port (if you wish):  For development environment it is useful to change data persisting policy port 6379 save 900 1 save 300 10 save 60 10000 save 10 1 save after 10 sec if at least 1 key changed
  • 4. Running Redis Server  Run /redis/bin/redis-server.exe and specify configuration file to use redis>redis-server redis.conf
  • 5. Running Redis Client  Run /redis/bin/redis-cli.exe  Now you can play with Redis a little bit
  • 6. Useful Commands  Print all keys:  Remove all keys from all databases  Synchronously save the dataset to disk KEYS * FLUSHALL SAVE
  • 7. Redis keys  Keys are binary safe - it is possible to use any binary sequence as a key  The empty string is also a valid key  Too long keys are not a good idea  Too short keys are often also not a good idea ("u:1000:pwd" versus "user:1000:password")  Nice idea is to use some kind of schema, like: "object-type:id:field"
  • 8. Redis data types Redis is often referred to as a data structure server since keys can contain:  Strings  Lists  Sets  Hashes  Sorted Sets
  • 10. Redis 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  Max length: (2^32 - 1) elements  Model a timeline in a social network, using LPUSH to add new elements, and using LRANGE in order to retrieve recent items  Use LPUSH together with LTRIM to create a list that never exceeds a given number of elements
  • 12. Redis 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
  • 13. Redis Hashes  Map between string fields and string values  Perfect data type to represent objects HMSET user:1000 username abhi password 123 age 28 HGETALL user:1000 HSET user:1000 password 12345 HGETALL user:1000
  • 14. Redis Operations It is possible to run atomic operations on data types:  appending to a string  incrementing the value in a hash  pushing to a list  computing set intersection, union and difference  getting the member with highest ranking in a sorted set
  • 15. Redis client  PHPRedis – PHP Client for Redis (https://github.com/nicolasff/phpredis)  JRedis - Java Client for Redis  Jedis - a blazingly small and sane Redis Java client  Spring Data Redis
  • 16. Configuration By Redis.conf port 6379 bind 127.0.0.1 maxclients 10000 maxmemory <bytes> By script $redis->config("GET", "*max-*-entries*"); $redis->config("SET", "dir", "/var/run/redis/dumps/");
  • 17. PHP code <?php $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $redis->set('key','value', 10); // Will set the key, if it doesn't exist, with a ttl of 10 seconds echo $redis->get(‘key’); ?>