Your SlideShare is downloading. ×
0
Redis, a 2 minutes introduction
Redis, a 2 minutes introduction
Redis, a 2 minutes introduction
Redis, a 2 minutes introduction
Redis, a 2 minutes introduction
Redis, a 2 minutes introduction
Redis, a 2 minutes introduction
Redis, a 2 minutes introduction
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Redis, a 2 minutes introduction

590

Published on

Redis a 5 minutes guide

Redis a 5 minutes guide

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
590
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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

×