+ All Categories
Home > Technology > Redis by-hari

Redis by-hari

Date post: 27-Jun-2015
Category:
Upload: hari-bachala
View: 174 times
Download: 0 times
Share this document with a friend
Description:
This presentation brief about what is Redis and some use cases of it.
Popular Tags:
24
Remote Dictionary Server Redis 1
Transcript
Page 1: Redis by-hari

1

Remote Dictionary Server

Redis

Presented By

HARI

Page 2: Redis by-hari

2

Agenda

I . Introduction Context, Popular Redis Users

II. Basics

How to use, Real time use cases , Data Types.

few Advance supported features …………

Transactions, public/subscribe, Clusters, Replication

Agenda

Page 3: Redis by-hari

3

Redis is an open source, networked, single threaded, in- memory Advanced key value store with optional

durability .

It is often referred to as a data structure server since keys can contain strings ,hashes, lists, sets, and sorted sets.

Context

Page 4: Redis by-hari

4

Popular Redis Users

Page 5: Redis by-hari

5

Document DBs

‣ Mongo DB, Couch DB,…

Graph DBs

‣ Neo4j, Flock DB…

Column oriented DBs

‣ HBase, Cassandra, BigTable…

Key-Value DBs

‣ Memcache, MemcacheDB, Redis,……

No SQL Data Bases

Page 6: Redis by-hari

6

Written in C(No external dependence)

Uses memory as main storage

Uses disk for persistence

Single Threaded

Fast performance

~50k read/write operations per second

Few Fundamentals

Page 7: Redis by-hari

7

How to use

Download Latest Version here

Extract it And start sever

configurations: redis.conf

Connect via client/s

For practice you can use http://try.redis.io/

Page 8: Redis by-hari

8

Arbitrary ASCII strings

‣ Define some format convention and adhere to it

‣ Key length matters!

Multiple name spaces are available

‣ Separate DBs indexed by an integer value

‣ SELECT command

Keys can expire automatically (if you specify TTL)

Keys

Page 9: Redis by-hari

9

Data Types

Page 10: Redis by-hari

10

• APPEND

• GET

• SET

• STRLEN

• INCR

• DECR

• INCRBY

• DECRBY

• few more #string commands

String Commands

Page 11: Redis by-hari

11

• LLEN

• LPOP

• LPUSH

• LRANGE

• LREM

• LINSERT

• RPOP

• RPUSH

Lists Commands

Page 12: Redis by-hari

12

• SADD

• SCARD

• SDIFF

• SMEMBERS

• SMOVE

• SPOP

• SREM

Sets Commands

Page 13: Redis by-hari

13

• ZADD

• ZCARD

• ZCOUNT

• ZRANGE

• ZRANK

• ZREM

• ZSCORE

• ZSCAN

Sorted Sets Commands

Page 14: Redis by-hari

14

C (hiredis,credis,libredis)

C# (ServiceStack.Redis,StackExchange.Redis) 

C++(redis3m, C++ Client)

Java(Jedis,Jredis, JDBC-Redis)

Perl(Redis, RedisDB)

PHP(Predis, phpredis)

• few more clients  

Redis Clients

Page 15: Redis by-hari

15

Public class TestJedis {

public static void main(String[] args) {

Jedis jedis = new Jedis("localhost");

jedis.set("key", "value");

System.out.println(jedis.get("key"));

}

}

Redis with java client (Jedis)

Page 16: Redis by-hari

16

Jedis(String host)

Jedis (String host, int port)

Maven dependency

<dependency>

<groupId>redis.clients</groupId>

<artifactId>jedis</artifactId>

<version>2.5.2</version>

</dependency>

Jedis constructor

Page 17: Redis by-hari

17

Redis pipelines are just a RTT optimization

‣Deliver multiple commands together without waiting for replies

‣Fetch all replies in a single step

‣ Server needs to buffer all replies!

Pipelines are NOT transactional or atomic

‣ Much more flexible alternative

Pipe lines

Page 18: Redis by-hari

18

Classic pattern decoupling publishers & subscribers

You can subscribe to channels; when someone publish in a channel matching your interests Redis will send it to you

PUBLISH

SUBSCRIBE,

UNSUBSCRIBE

Publish/Subscribe

Page 19: Redis by-hari

19

Commands are executed as an atomic & single isolated operation

DISCARD

MULTI

EXEC

Transactions

Page 20: Redis by-hari

20

One master — Multiple slaves

Scalability & redundancy

Client side failover, eviction, query routing…

Slaves are able to accept other slave connections

Asynchronous but periodically acknowledged

Automatic slave reconnection

Replication

Page 21: Redis by-hari

21

Released in Redis 3.0

High performance & linearly scalable complex distributed DB

Sharding across multiple nodes

Graceful handling of network partitions

Redis Cluster

Page 22: Redis by-hari

22

Need a faster response

Need a Atomic operations

Need a transactions

Need a publish/subscribe model

Support for persistence

Job queue, session store, Real Time Ranking

Real Time Use cases

Page 23: Redis by-hari

23

Name Memchahe Redis

Description In-memory key-value store, originally intended for caching

In-memory database with configurable options performance vs. persistency 

Release : 2003 2009

Implementation language C C

Server-side scripts NO Lua

Replication methods None Master-Slave

SQL No NO

Database model Key-value Key-value

Database schema No NO

Supported programming languages Net,C,C++,ColdFusion,Erlang,Java,LispLua,Ocaml,Perl,PHP,Python,Ruby

C,C#,C++,Clojure,Dart,Erlang,Go,Java,JavaScript,Lisp,Lua,Objective-CPerl,PHP,Python,Ruby,Scala,SmalltalkTcl

Redis vs Memcache

Page 24: Redis by-hari

24

FastSimpleReliable

PredictableLight weight

Widely supported

Summary


Recommended