SlideShare a Scribd company logo
1 of 8
Download to read offline
Redis:Getting
started (5 min
guide)
A noSQL database quick and fast and
almost Italian :)
What is Redis
Is an advanced key-value store.
A redis serve can contain the following data structures:
● strings
● hashes
● lists
● sets
● sorted sets
Installing
Linux
$ wget http://download.redis.io/releases/redis-2.6.16.tar.gz
$ tar xzf redis-2.6.16.tar.gz
$ cd redis-2.6.16
$ make

Mac Users:
$ port install redis
$ brew install redis
Windows:
ops :(
Getting started 1
Start the server
$ redis-server
_._

_.-``__ ''-._
_.-``

`. `_. ''-._

.-`` .-```. ```/
(

'

,

Redis 2.6.16 (00000000/0) 64 bit

_.,_ ''-._

.-` | `,

)

Running in stand alone mode

|`-._`-...-` __...-.``-._|'` _.-'|
|

`-._

`-._

`._

`-.__.-'

`-._`-._

`-._

`-._`-._

`-._

_.-'_.-'

`-.__.-'

`-._

|

http://redis.io

_.-'

_.-'_.-'|

`-._`-.__.-'_.-'

`-._

Port: 6379

PID: 7350

_.-'

_.-'_.-'
`-.__.-'

|

_.-'_.-'|

`-._`-.__.-'_.-'

|`-._`-._
|

_.-'

`-._ `-./ _.-'

|`-._`-._
|

/

|
_.-'

_.-'

_.-'

`-.__.-'
[7350] 10 Sep 13:03:33.329 # Server started, Redis version 2.6.16
[7350] 10 Sep 13:03:33.329 * The server is now ready to accept connections on port 6379
Getting started 2
Start the server
$ redis-client

_._

redis 127.0.0.1:6379> get foo
"mirko2"
redis 127.0.0.1:6379> set counter 100
OK
redis 127.0.0.1:6379> incr counter
(integer) 101
redis 127.0.0.1:6379> RPUSH mylist "Mirko"
(integer) 1
redis 127.0.0.1:6379> RPUSH mylist "Mario"
(integer) 2
redis 127.0.0.1:6379> RPUSH mylist "Fabio"
(integer) 3
redis 127.0.0.1:6379> lrange mylist 0 2
1) "Mirko"
2) "Mario"
3) "Fabio"
Try redit
Interactive console with the commands available
http://try.redis.io/
Even more...
Creating a simple hashmap
Hashes
Redis Hashes are maps between string fields and string values, so they are the perfect data type to represent objects (eg: A User with a
number of fields like name, surname, age, and so forth):

redis 127.0.0.1:6379> HMSET user:1 username antirez password Mirko age 33
OK
redis 127.0.0.1:6379> HGETALL user:1
1) "username"
2) "antirez"
3) "password"
4) "Mirko"
5) "age"
6) "33"

Want to check is a user exists? (Login)
HMGET user:1000 password password
Ok, perfect. But what in
Java?
Very nice and easy project is
https://github.com/xetorthio/jedis
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.0.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

Jedis jedis = new Jedis("localhost");
jedis.set("foo", "bar");
String value = jedis.get("foo");

More Related Content

What's hot

WebClusters, Redis
WebClusters, RedisWebClusters, Redis
WebClusters, Redis
Filip Tepper
 
Administration
AdministrationAdministration
Administration
MongoSF
 
Setting up mongo replica set
Setting up mongo replica setSetting up mongo replica set
Setting up mongo replica set
Sudheer Kondla
 
Empacotamento e backport de aplicações em debian
Empacotamento e backport de aplicações em debianEmpacotamento e backport de aplicações em debian
Empacotamento e backport de aplicações em debian
Andre Ferraz
 

What's hot (19)

Caching solutions with Redis
Caching solutions   with RedisCaching solutions   with Redis
Caching solutions with Redis
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
 
WebClusters, Redis
WebClusters, RedisWebClusters, Redis
WebClusters, Redis
 
How do i Meet MongoDB
How do i Meet MongoDBHow do i Meet MongoDB
How do i Meet MongoDB
 
Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)
 
杨卫华:微博cache设计浅谈
杨卫华:微博cache设计浅谈杨卫华:微博cache设计浅谈
杨卫华:微博cache设计浅谈
 
Dockerの準備
Dockerの準備Dockerの準備
Dockerの準備
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
 
Day 2-some fun coding
Day 2-some fun codingDay 2-some fun coding
Day 2-some fun coding
 
はじめてのGlusterFS
はじめてのGlusterFSはじめてのGlusterFS
はじめてのGlusterFS
 
Administration
AdministrationAdministration
Administration
 
Tech talk Introduction to containers
Tech talk Introduction to containersTech talk Introduction to containers
Tech talk Introduction to containers
 
Setting up mongo replica set
Setting up mongo replica setSetting up mongo replica set
Setting up mongo replica set
 
Empacotamento e backport de aplicações em debian
Empacotamento e backport de aplicações em debianEmpacotamento e backport de aplicações em debian
Empacotamento e backport de aplicações em debian
 
Solaris 11 base box for Vagrant using Packer
Solaris 11 base box for Vagrant using PackerSolaris 11 base box for Vagrant using Packer
Solaris 11 base box for Vagrant using Packer
 
Introduction to MongoDB with PHP
Introduction to MongoDB with PHPIntroduction to MongoDB with PHP
Introduction to MongoDB with PHP
 
Unix 6 en
Unix 6 enUnix 6 en
Unix 6 en
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 

Similar to Redis, a 2 minutes introduction

quickguide-einnovator-10-redis-admin
quickguide-einnovator-10-redis-adminquickguide-einnovator-10-redis-admin
quickguide-einnovator-10-redis-admin
jorgesimao71
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记
yongboy
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记
锐 张
 

Similar to Redis, a 2 minutes introduction (20)

Redispresentation apac2012
Redispresentation apac2012Redispresentation apac2012
Redispresentation apac2012
 
quickguide-einnovator-10-redis-admin
quickguide-einnovator-10-redis-adminquickguide-einnovator-10-redis-admin
quickguide-einnovator-10-redis-admin
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记
 
Infrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleInfrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & Ansible
 
Take care of hundred containers and not go crazy
Take care of hundred containers and not go crazyTake care of hundred containers and not go crazy
Take care of hundred containers and not go crazy
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记
 
Redis clustering
Redis clusteringRedis clustering
Redis clustering
 
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 introduction
Redis introductionRedis introduction
Redis introduction
 
Genode Compositions
Genode CompositionsGenode Compositions
Genode Compositions
 
Redis 101
Redis 101Redis 101
Redis 101
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
Freeradius edir
Freeradius edirFreeradius edir
Freeradius edir
 
MySQL cluster workshop
MySQL cluster workshopMySQL cluster workshop
MySQL cluster workshop
 
What’s New in Docker - Victor Vieux, Docker
What’s New in Docker - Victor Vieux, DockerWhat’s New in Docker - Victor Vieux, Docker
What’s New in Docker - Victor Vieux, Docker
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
grate techniques
grate techniquesgrate techniques
grate techniques
 
Redis acc
Redis accRedis acc
Redis acc
 
Linux Containers (LXC)
Linux Containers (LXC)Linux Containers (LXC)
Linux Containers (LXC)
 
Redis
RedisRedis
Redis
 

Recently uploaded

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 

Redis, a 2 minutes introduction

  • 1. Redis:Getting started (5 min guide) A noSQL database quick and fast and almost Italian :)
  • 2. What is Redis Is an advanced key-value store. A redis serve can contain the following data structures: ● strings ● hashes ● lists ● sets ● sorted sets
  • 3. Installing Linux $ wget http://download.redis.io/releases/redis-2.6.16.tar.gz $ tar xzf redis-2.6.16.tar.gz $ cd redis-2.6.16 $ make Mac Users: $ port install redis $ brew install redis Windows: ops :(
  • 4. Getting started 1 Start the server $ redis-server _._ _.-``__ ''-._ _.-`` `. `_. ''-._ .-`` .-```. ```/ ( ' , Redis 2.6.16 (00000000/0) 64 bit _.,_ ''-._ .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| | `-._ `-._ `._ `-.__.-' `-._`-._ `-._ `-._`-._ `-._ _.-'_.-' `-.__.-' `-._ | http://redis.io _.-' _.-'_.-'| `-._`-.__.-'_.-' `-._ Port: 6379 PID: 7350 _.-' _.-'_.-' `-.__.-' | _.-'_.-'| `-._`-.__.-'_.-' |`-._`-._ | _.-' `-._ `-./ _.-' |`-._`-._ | / | _.-' _.-' _.-' `-.__.-' [7350] 10 Sep 13:03:33.329 # Server started, Redis version 2.6.16 [7350] 10 Sep 13:03:33.329 * The server is now ready to accept connections on port 6379
  • 5. Getting started 2 Start the server $ redis-client _._ redis 127.0.0.1:6379> get foo "mirko2" redis 127.0.0.1:6379> set counter 100 OK redis 127.0.0.1:6379> incr counter (integer) 101 redis 127.0.0.1:6379> RPUSH mylist "Mirko" (integer) 1 redis 127.0.0.1:6379> RPUSH mylist "Mario" (integer) 2 redis 127.0.0.1:6379> RPUSH mylist "Fabio" (integer) 3 redis 127.0.0.1:6379> lrange mylist 0 2 1) "Mirko" 2) "Mario" 3) "Fabio"
  • 6. Try redit Interactive console with the commands available http://try.redis.io/
  • 7. Even more... Creating a simple hashmap Hashes Redis Hashes are maps between string fields and string values, so they are the perfect data type to represent objects (eg: A User with a number of fields like name, surname, age, and so forth): redis 127.0.0.1:6379> HMSET user:1 username antirez password Mirko age 33 OK redis 127.0.0.1:6379> HGETALL user:1 1) "username" 2) "antirez" 3) "password" 4) "Mirko" 5) "age" 6) "33" Want to check is a user exists? (Login) HMGET user:1000 password password
  • 8. Ok, perfect. But what in Java? Very nice and easy project is https://github.com/xetorthio/jedis <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.0.0</version> <type>jar</type> <scope>compile</scope> </dependency> Jedis jedis = new Jedis("localhost"); jedis.set("foo", "bar"); String value = jedis.get("foo");