SlideShare a Scribd company logo
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

PPTX
A simple introduction to redis
PDF
MongoDB Shard Cluster
KEY
Redis overview for Software Architecture Forum
PDF
Redis and its many use cases
PDF
Connect dell equallogic storage to linux instance
PDF
Backup UUASC 9/6/12
PPTX
Unix cmd on_free_bsd
PDF
MongoDB Replication Cluster
A simple introduction to redis
MongoDB Shard Cluster
Redis overview for Software Architecture Forum
Redis and its many use cases
Connect dell equallogic storage to linux instance
Backup UUASC 9/6/12
Unix cmd on_free_bsd
MongoDB Replication Cluster

What's hot (19)

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

Similar to Redis, a 2 minutes introduction (20)

PDF
Getting Started with Redis
PDF
quickguide-einnovator-10-redis-admin
PPTX
Introduction to Redis
PDF
Redispresentation apac2012
PDF
Redis overview
PDF
dba_lounge_Iasi: Everybody likes redis
PDF
quickguide-einnovator-9-redis
PPTX
Get more than a cache back! - ConFoo Montreal
PDF
Redis Installation Configuration And Implementation
PPTX
Redis_Presentation.pptx ppt on redis and
PPTX
PDF
An Introduction to Redis for Developers.pdf
PPT
PDF
Redis : NoSQL key-data store
PDF
Redis 101
PDF
Steam Learn: An introduction to Redis
PDF
Introduction to Redis
PPTX
Redis. Seattle Data Science and Data Engineering Meetup
PDF
#SydPHP - The Magic of Redis
PDF
Getting Started with Redis
Getting Started with Redis
quickguide-einnovator-10-redis-admin
Introduction to Redis
Redispresentation apac2012
Redis overview
dba_lounge_Iasi: Everybody likes redis
quickguide-einnovator-9-redis
Get more than a cache back! - ConFoo Montreal
Redis Installation Configuration And Implementation
Redis_Presentation.pptx ppt on redis and
An Introduction to Redis for Developers.pdf
Redis : NoSQL key-data store
Redis 101
Steam Learn: An introduction to Redis
Introduction to Redis
Redis. Seattle Data Science and Data Engineering Meetup
#SydPHP - The Magic of Redis
Getting Started with Redis
Ad

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Spectral efficient network and resource selection model in 5G networks
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
“AI and Expert System Decision Support & Business Intelligence Systems”
Programs and apps: productivity, graphics, security and other tools
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
Approach and Philosophy of On baking technology
20250228 LYD VKU AI Blended-Learning.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

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");