SlideShare a Scribd company logo
1 of 18
Download to read offline
http://dogancan.net
NEDİR?
➤ REmoteDİctionaryServer
➤ keyvaluetipindenoSQLveritabanı
➤ Persistence
➤ Zenginveritipidesteği
➤ ANSIC
➤ SalvatoreSanfilippo(http://antirez.com)
➤ DestekleyenRedislabs.ÖncesindePivotalandVMware
http://dogancan.net
https://db-engines.com/en/ranking
POPÜLERLİK ENDEKSLERİ
KEY VALUE DBMSTÜM DBMS
http://dogancan.net
http://techstacks.io/tech/redis
KİMLER KULLANIYOR?
➤ Twitter
➤ GitHub
➤ Weibo
➤ Pinterest
➤ Snapchat
➤ Craigslist
➤ Digg
➤ StackOverflow
➤ Flickr
http://dogancan.net
MEMCACHED İLE KARŞILAŞTIRMA
➤ Memcached
➤ DataRAMdedepolanır
➤ Veritipisadecestring
➤ Redis
➤ DataRAMdefakatdisktede
depolanır.
➤ Veritipleriçeşitli
http://dogancan.net
CLIENTS
http://dogancan.net
ÖZELLİKLER
× Farklı veri tipleri
× Expire
× Pipeline
× Transaction
× Pub/Sub
× Lua Script
× Kolay Replication
http://dogancan.net
KURULUM
DOCKER
$ wget http://download.redis.io/releases/redis-3.2.9.tar.gz
$ tar xzf redis-3.2.9.tar.gz
$ cd redis-3.2.9
$ make
$ src/redis-server
$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
LINUX
Kurulumsuz denemek için http://try.redis.io/
http://dogancan.net
BENCHMARK
$ docker run --name redis101 -d redis redis-server --appendonly yes
Persistence
127.0.0.1:6379> redis-benchmark -q -n 100000
root@3b41d7b54345:/data# redis-benchmark -q -n 100000
PING_INLINE: 48402.71 requests per second
PING_BULK: 48332.53 requests per second
SET: 51072.52 requests per second
GET: 52192.07 requests per second
INCR: 52631.58 requests per second
LPUSH: 51203.28 requests per second
RPUSH: 53937.43 requests per second
LPOP: 52328.62 requests per second
RPOP: 53908.36 requests per second
SADD: 52493.44 requests per second
SPOP: 51020.41 requests per second
LPUSH (needed to benchmark LRANGE): 53590.57 requests per second
LRANGE_100 (first 100 elements): 26759.43 requests per second
LRANGE_300 (first 300 elements): 12210.01 requests per second
LRANGE_500 (first 450 elements): 7393.17 requests per second
LRANGE_600 (first 600 elements): 7299.80 requests per second
MSET (10 keys): 42589.44 requests per second
root@9012bab64961:/# redis-benchmark -q -n 100000
PING_INLINE: 59523.81 requests per second
PING_BULK: 57537.40 requests per second
SET: 56179.78 requests per second
GET: 59808.61 requests per second
INCR: 60060.06 requests per second
LPUSH: 58038.30 requests per second
RPUSH: 59276.82 requests per second
LPOP: 60975.61 requests per second
RPOP: 57870.37 requests per second
SADD: 59523.81 requests per second
SPOP: 58445.36 requests per second
LPUSH (needed to benchmark LRANGE): 58479.53 requests per second
LRANGE_100 (first 100 elements): 35435.86 requests per second
LRANGE_300 (first 300 elements): 17488.63 requests per second
LRANGE_500 (first 450 elements): 12624.67 requests per second
LRANGE_600 (first 600 elements): 10293.36 requests per second
MSET (10 keys): 53447.35 requests per second
Run the benchmark with the default configuration against 127.0.0.1:6379:
$ redis-benchmark
Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:
$ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20
Fill 127.0.0.1:6379 with about 1 million keys only using the SET test:
$ redis-benchmark -t set -n 1000000 -r 100000000
Benchmark 127.0.0.1:6379 for a few commands producing CSV output:
$ redis-benchmark -t ping,set,get -n 100000 --csv
Benchmark a specific command line:
$ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0
Fill a list with 10000 random elements:
$ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__
http://dogancan.net
VERİ TİPLERİ
× Strings
× Lists
× Hashes
× Sets
× Sorted sets
× Geo
APPEND
BITCOUNT
BITFIELD
BITOP
BITPOS
DECR
DECRBY
GET
GETBIT
GETRANGE
GETSET
INCR
INCRBY
INCRBYFLOAT
MGET
MSET
MSETNX
PSETEX
SET
SETBIT
SETEX
SETNX
SETRANGE
STRLEN
127.0.0.1:6379> SET falan filan
OK
127.0.0.1:6379> GET falan
"filan"
127.0.0.1:6379> GET falan vesaire
(error) ERR wrong number of arguments for 'get' command
127.0.0.1:6379> MGET falan vesaire
1) "filan"
2) (nil)
127.0.0.1:6379> INCR sayac
(integer) 1
127.0.0.1:6379> INCR sayac
(integer) 2
127.0.0.1:6379> GET sayac
"2"
127.0.0.1:6379> INCRBY sayac 10
(integer) 12
127.0.0.1:6379> GET sayac
“12"
127.0.0.1:6379> DECR sayac
(integer) 11
127.0.0.1:6379> GET sayac
“11"
http://dogancan.net
VERİ TİPLERİ - LISTS
127.0.0.1:6379> LPUSH 34duraklari "AVCILAR"
(integer) 1
127.0.0.1:6379> LPUSH 34duraklari "INCIRLI"
(integer) 2
127.0.0.1:6379> LINDEX 34duraklari 0
"INCIRLI"
127.0.0.1:6379> LINDEX 34duraklari 1
"AVCILAR"
127.0.0.1:6379> LPUSH 34duraklari ZINCIRLIKUYU
(integer) 3
127.0.0.1:6379> LRANGE 34duraklari 0 3
1) "ZINCIRLIKUYU"
2) "INCIRLI"
3) "AVCILAR"
127.0.0.1:6379> LINSERT 34duraklari BEFORE "INCIRLI" "CEVIZLIBAG"
(integer) 4
127.0.0.1:6379> LRANGE 34duraklari 0 3
1) "ZINCIRLIKUYU"
2) "CEVIZLIBAG"
3) "INCIRLI"
4) “AVCILAR"
127.0.0.1:6379> LPOP 34duraklari
"ZINCIRLIKUYU"
127.0.0.1:6379> LRANGE 34duraklari 0 3
1) "CEVIZLIBAG"
2) "INCIRLI"
3) “AVCILAR"
127.0.0.1:6379> RPOP 34duraklari
"AVCILAR"
127.0.0.1:6379> LRANGE 34duraklari 0 3
1) "CEVIZLIBAG"
2) "INCIRLI"
BLPOP
BRPOP
BRPOPLPUSH
LINDEX
LINSERT
LLEN
LPOP
LPUSH
LPUSHX
LRANGE
LREM
LSET
LTRIM
RPOP
RPOPLPUSH
RPUSH
RPUSHX
× Strings
× Lists
× Hashes
× Sets
× Sorted sets
× Geo
http://dogancan.net
VERİ TİPLERİ - HASHES
× Strings
× Lists
× Hashes
× Sets
× Sorted sets
× Geo
127.0.0.1:6379> HSET user1 name Dogan
(integer) 1
127.0.0.1:6379> HSET user1 surname Can
(integer) 1
127.0.0.1:6379> HGETALL user1
1) "name"
2) "Dogan"
3) "surname"
4) "Can"
127.0.0.1:6379> HGET user1 name
"Dogan"
127.0.0.1:6379> HGET user1 surname
"Can"
127.0.0.1:6379> HSET user1 yas 38
(integer) 1
127.0.0.1:6379> HINCRBY user1 yas 1
(integer) 39
127.0.0.1:6379> HSET user3 name "Omer" surname "Can"
(error) ERR wrong number of arguments for 'hset' command
127.0.0.1:6379> HMSET user3 name "Omer" surname "Can"
OK
127.0.0.1:6379> HMGET user3 name
1) "Omer"
127.0.0.1:6379> HMGET user3 name surname yas
1) "Omer"
2) "Can"
3) (nil)
HDEL
HEXISTS
HGET
HGETALL
HINCRBY
HINCRBYFLOAT
HKEYS
HLEN
HMGET
HMSET
HSCAN
HSET
HSETNX
HSTRLEN
HVALS
http://dogancan.net
VERİ TİPLERİ - SETS
127.0.0.1:6379> SADD 34 AVCILAR INCIRLI CEVIZLIBAG ZINCIRLIKUYU
(integer) 4
127.0.0.1:6379> SMEMBERS 34
1) "CEVIZLIBAG"
2) "ZINCIRLIKUYU"
3) "INCIRLI"
4) "AVCILAR"
127.0.0.1:6379> SADD 34AS CEVIZLIBAG ZINCIRLIKUYU UNALAN KADIKOY
(integer) 4
127.0.0.1:6379> SMEMBERS 34AS
1) "CEVIZLIBAG"
2) "KADIKOY"
3) "ZINCIRLIKUYU"
4) "UNALAN"
127.0.0.1:6379> SDIFF 34 34AS
1) "INCIRLI"
2) "AVCILAR"
127.0.0.1:6379> SDIFF 34AS 34
1) "KADIKOY"
2) "UNALAN"
127.0.0.1:6379> SDIFFSTORE ortakduraklar 34 34AS
SADD
SCARD
SDIFF
SDIFFSTORE
SINTER
SINTERSTORE
SISMEMBER
SMEMBERS
SMOVE
SPOP
SRANDMEMBER
SREM
SSCAN
SUNION
SUNIONSTORE
× Strings
× Lists
× Hashes
× Sets
× Sorted sets
× Geo
http://dogancan.net
VERİ TİPLERİ - GEO
× Strings
× Lists
× Hashes
× Sets
× Sorted sets
× Geo
{
"06:00": {
"TA001": {
"lat": "40.93486",
"lng": "29.141796"
},
"O3059": {
"lat": "41.001045",
"lng": "29.077938"
},
"K1700": {
"lat": "40.978718",
"lng": "29.237024"
},
"M2523": {
"lat": "41.05971",
"lng": "28.790985"
},
"K1763": {
"lat": "41.06437",
"lng": "28.95947"
},
"M3016": {
"lat": "41.06643",
"lng": "29.012556"
}
},
GEOADD
GEODIST
GEOHASH
GEOPOS
GEORADIUS
GEORADIUSBYMEMBER
127.0.0.1:6379> GEOPOS saat:06:00 TA001
1) 1) "29.14179593324661255"
2) “40.93486083827887256"
127.0.0.1:6379> GEODIST saat:06:00 TA001 M3016 km
"18.2167"
127.0.0.1:6379> GEORADIUSBYMEMBER saat:06:00 TA001 10 km
1) "TA001"
2) "O3059"
3) "K1700"
127.0.0.1:6379> GEORADIUSBYMEMBER saat:06:00 TA001 100 km
1) "M2523"
2) "TA001"
3) "O3059"
4) "K1763"
5) "M3016"
6) "K1700"
127.0.0.1:6379> GEOHASH saat:06:00 TA001
1) "sxk8z5uqv50"
127.0.0.1:6379> GEORADIUS saat:06:00 28.980 41.0673 10 km WITHCOORD WITHDIST
1) 1) "K1763"
2) "1.7522"
3) 1) "28.95947009325027466"
2) "41.06436988119413201"
2) 1) "M3016"
2) "2.7318"
3) 1) "29.01255637407302856"
2) "41.06643060949667756"
19 $jsonstr = file_get_contents("data.json");
20 $arr = json_decode($jsonstr);
21 foreach ($arr as $saat=>$bus) {
22 foreach ($bus as $kapino=>$latlng) {
23 # GEOADD saat:06:00 29.141796 40.93486 TA001
24 $client->geoadd("saat:".$saat,$latlng->lng, $latlng->lat, $kapino);
25 }
26 }
http://geohash.org/sxk8z5uqv50
http://dogancan.net
ÖRNEK - REPLICATION
$ docker run --name redis-master -p 6000:6379 -d redis redis-server --appendonly yes
$ docker run --name redis-slave1 -p 6001:6379 -d redis redis-server --appendonly yes
$ docker exec redis-slave1 redis-cli slaveof 192.168.99.100 6000
$ docker exec redis-slave2 redis-cli slaveof 192.168.99.100 6000
$ docker run --name redis-slave2 -p 6002:6379 -d redis redis-server --appendonly yes
1 <?php
2 #  client.php
3
4 require "/vendor/autoload.php";
5
6 $client = new PredisClient([
7 'scheme' => 'tcp',
8 'host' => '192.168.99.100',
9 'port' => 6000,
10 ]);
11
12 $status = $client->set("user1", "Dogan Can");
13 echo "SET sonucu:".$status;
14 echo "n";
15
16 $result = $client->get("user1");
17 echo "GET sonucu:n";
18 var_dump($result);
$ composer require predis/predis
$ php clients.php
Php Uygulaması
Docker container ayarı
$ docker run --name redis-master 
-p 6000:6379 
-e REDIS_REPLICATION_MODE=master 
-e REDIS_PASSWORD=masterp 
-d bitnami/redis:latest
$ docker run --name redis-slave 
-p 6001:6379 
-e REDIS_REPLICATION_MODE=slave 
-e REDIS_MASTER_HOST=10.100.2.205 
-e REDIS_MASTER_PORT=6000 
-e REDIS_MASTER_PASSWORD=masterp 
-e REDIS_PASSWORD=p 
-d bitnami/redis:latest
http://dogancan.net
PUB/SUB
PSUBSCRIBE
PUBLISH
PUBSUB
PUNSUBSCRIBE
SUBSCRIBE
UNSUBSCRIBE
1 <?php
2 # pub.php
3
4 include __DIR__ . "/vendor/autoload.php";
5
6 $client = new PredisClient([
7 'scheme' => 'tcp',
8 'host' => '192.168.99.100',
9 'port' => 6000,
10 ]);
11
12 $durak = $client->lpop("34");
13
14 $client->publish('34', $durak.' duragindan gecti');
1 <?<php
2 // Ilgili socket surekli dinleniyor
3 ini_set("default_socket_timeout", -1);
4
5 require "vendor/autoload.php";
6
7 $client = new PredisClient([
8 'scheme' => 'tcp',
9 'host' => '192.168.99.100',
10 'port' => 6000,
11 ]);
12
13 $consumer = new PredisPubSubConsumer($client);
14
15 $loop = new PredisPubSubDispatcherLoop($consumer);
16
17 $loop->attachCallback('34', 'show');
18 $loop->run();
19
20 function show($data) {
21 static $i = 0;
22 echo ++$i . '.' . $data . PHP_EOL;
23 }
http://dogancan.net
rename-command FLUSHDB ""
rename-command FLUSHALL ""
BAZI ÖZEL DURUMLAR
http://dogancan.net
./webdis &
curl http://127.0.0.1:7379/SET/hello/world
→ {"SET":[true,"OK"]}
curl http://127.0.0.1:7379/GET/hello
→ {"GET":"world"}
curl -d "GET/hello" http://127.0.0.1:7379/
→ {"GET":"world"}
EKSTRA : WEBDİS
http://dogancan.net

More Related Content

What's hot

X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
Parallel Computing With Dask - PyDays 2017
Parallel Computing With Dask - PyDays 2017Parallel Computing With Dask - PyDays 2017
Parallel Computing With Dask - PyDays 2017Christian Aichinger
 
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeSCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeJeff Frost
 
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)MongoSF
 
M12 random forest-part01
M12 random forest-part01M12 random forest-part01
M12 random forest-part01Raman Kannan
 
M11 bagging loo cv
M11 bagging loo cvM11 bagging loo cv
M11 bagging loo cvRaman Kannan
 
Common Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsCommon Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsOdoo
 
Best Practices in Handling Performance Issues
Best Practices in Handling Performance IssuesBest Practices in Handling Performance Issues
Best Practices in Handling Performance IssuesOdoo
 
M09-Cross validating-naive-bayes
M09-Cross validating-naive-bayesM09-Cross validating-naive-bayes
M09-Cross validating-naive-bayesRaman Kannan
 
Kubernetes Tutorial
Kubernetes TutorialKubernetes Tutorial
Kubernetes TutorialCi Jie Li
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapTests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapRodolphe Quiédeville
 
Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)
Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)
Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)Spark Summit
 
The InfluxDB 2.0 Storage Engine | Jacob Marble | InfluxData
The InfluxDB 2.0 Storage Engine | Jacob Marble | InfluxDataThe InfluxDB 2.0 Storage Engine | Jacob Marble | InfluxData
The InfluxDB 2.0 Storage Engine | Jacob Marble | InfluxDataInfluxData
 
SequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational DatabaseSequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational Databasewangzhonnew
 
Capital onehadoopclass
Capital onehadoopclassCapital onehadoopclass
Capital onehadoopclassDoug Chang
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-pythonEric Ahn
 

What's hot (20)

X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Containers for sysadmins
Containers for sysadminsContainers for sysadmins
Containers for sysadmins
 
Parallel Computing With Dask - PyDays 2017
Parallel Computing With Dask - PyDays 2017Parallel Computing With Dask - PyDays 2017
Parallel Computing With Dask - PyDays 2017
 
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeSCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
 
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp KrennJavantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
 
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)
 
M12 random forest-part01
M12 random forest-part01M12 random forest-part01
M12 random forest-part01
 
M11 bagging loo cv
M11 bagging loo cvM11 bagging loo cv
M11 bagging loo cv
 
Crack.ba
Crack.baCrack.ba
Crack.ba
 
Common Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsCommon Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo apps
 
Best Practices in Handling Performance Issues
Best Practices in Handling Performance IssuesBest Practices in Handling Performance Issues
Best Practices in Handling Performance Issues
 
M09-Cross validating-naive-bayes
M09-Cross validating-naive-bayesM09-Cross validating-naive-bayes
M09-Cross validating-naive-bayes
 
Kubernetes Tutorial
Kubernetes TutorialKubernetes Tutorial
Kubernetes Tutorial
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapTests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTap
 
Dtalk shell
Dtalk shellDtalk shell
Dtalk shell
 
Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)
Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)
Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)
 
The InfluxDB 2.0 Storage Engine | Jacob Marble | InfluxData
The InfluxDB 2.0 Storage Engine | Jacob Marble | InfluxDataThe InfluxDB 2.0 Storage Engine | Jacob Marble | InfluxData
The InfluxDB 2.0 Storage Engine | Jacob Marble | InfluxData
 
SequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational DatabaseSequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational Database
 
Capital onehadoopclass
Capital onehadoopclassCapital onehadoopclass
Capital onehadoopclass
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-python
 

Similar to Redis 101

(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014Amazon Web Services
 
Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...
Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...
Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...Databricks
 
IT Days - Parse huge JSON files in a streaming way.pptx
IT Days - Parse huge JSON files in a streaming way.pptxIT Days - Parse huge JSON files in a streaming way.pptx
IT Days - Parse huge JSON files in a streaming way.pptxAndrei Negruti
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humansCraig Kerstiens
 
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...ZFConf Conference
 
Профилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаПрофилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаsamsolutionsby
 
WebClusters, Redis
WebClusters, RedisWebClusters, Redis
WebClusters, RedisFilip Tepper
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?Jeremy Schneider
 
Spark And Cassandra: 2 Fast, 2 Furious
Spark And Cassandra: 2 Fast, 2 FuriousSpark And Cassandra: 2 Fast, 2 Furious
Spark And Cassandra: 2 Fast, 2 FuriousJen Aman
 
Spark and Cassandra 2 Fast 2 Furious
Spark and Cassandra 2 Fast 2 FuriousSpark and Cassandra 2 Fast 2 Furious
Spark and Cassandra 2 Fast 2 FuriousRussell Spitzer
 
MongoDB World 2019: RDBMS Versus MongoDB Aggregation Performance
MongoDB World 2019: RDBMS Versus MongoDB Aggregation PerformanceMongoDB World 2019: RDBMS Versus MongoDB Aggregation Performance
MongoDB World 2019: RDBMS Versus MongoDB Aggregation PerformanceMongoDB
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby SystemsEngine Yard
 
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break GlassCassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glassaaronmorton
 
Cassandra Community Webinar | In Case of Emergency Break Glass
Cassandra Community Webinar | In Case of Emergency Break GlassCassandra Community Webinar | In Case of Emergency Break Glass
Cassandra Community Webinar | In Case of Emergency Break GlassDataStax
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterAndrey Kudryavtsev
 
bioinfolec7th20071005
bioinfolec7th20071005bioinfolec7th20071005
bioinfolec7th20071005guest0fd313
 
bioinfolec_7th_20071005
bioinfolec_7th_20071005bioinfolec_7th_20071005
bioinfolec_7th_20071005sesejun
 

Similar to Redis 101 (20)

(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
 
Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...
Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...
Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...
 
IT Days - Parse huge JSON files in a streaming way.pptx
IT Days - Parse huge JSON files in a streaming way.pptxIT Days - Parse huge JSON files in a streaming way.pptx
IT Days - Parse huge JSON files in a streaming way.pptx
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humans
 
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
 
Профилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаПрофилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кода
 
WebClusters, Redis
WebClusters, RedisWebClusters, Redis
WebClusters, Redis
 
Cassandra
CassandraCassandra
Cassandra
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Spark And Cassandra: 2 Fast, 2 Furious
Spark And Cassandra: 2 Fast, 2 FuriousSpark And Cassandra: 2 Fast, 2 Furious
Spark And Cassandra: 2 Fast, 2 Furious
 
Spark and Cassandra 2 Fast 2 Furious
Spark and Cassandra 2 Fast 2 FuriousSpark and Cassandra 2 Fast 2 Furious
Spark and Cassandra 2 Fast 2 Furious
 
MongoDB World 2019: RDBMS Versus MongoDB Aggregation Performance
MongoDB World 2019: RDBMS Versus MongoDB Aggregation PerformanceMongoDB World 2019: RDBMS Versus MongoDB Aggregation Performance
MongoDB World 2019: RDBMS Versus MongoDB Aggregation Performance
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby Systems
 
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break GlassCassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
 
Cassandra Community Webinar | In Case of Emergency Break Glass
Cassandra Community Webinar | In Case of Emergency Break GlassCassandra Community Webinar | In Case of Emergency Break Glass
Cassandra Community Webinar | In Case of Emergency Break Glass
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
 
bioinfolec7th20071005
bioinfolec7th20071005bioinfolec7th20071005
bioinfolec7th20071005
 
bioinfolec_7th_20071005
bioinfolec_7th_20071005bioinfolec_7th_20071005
bioinfolec_7th_20071005
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 

Recently uploaded

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 

Recently uploaded (20)

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 

Redis 101

  • 2. NEDİR? ➤ REmoteDİctionaryServer ➤ keyvaluetipindenoSQLveritabanı ➤ Persistence ➤ Zenginveritipidesteği ➤ ANSIC ➤ SalvatoreSanfilippo(http://antirez.com) ➤ DestekleyenRedislabs.ÖncesindePivotalandVMware http://dogancan.net
  • 4. http://techstacks.io/tech/redis KİMLER KULLANIYOR? ➤ Twitter ➤ GitHub ➤ Weibo ➤ Pinterest ➤ Snapchat ➤ Craigslist ➤ Digg ➤ StackOverflow ➤ Flickr http://dogancan.net
  • 5. MEMCACHED İLE KARŞILAŞTIRMA ➤ Memcached ➤ DataRAMdedepolanır ➤ Veritipisadecestring ➤ Redis ➤ DataRAMdefakatdisktede depolanır. ➤ Veritipleriçeşitli http://dogancan.net
  • 7. ÖZELLİKLER × Farklı veri tipleri × Expire × Pipeline × Transaction × Pub/Sub × Lua Script × Kolay Replication http://dogancan.net
  • 8. KURULUM DOCKER $ wget http://download.redis.io/releases/redis-3.2.9.tar.gz $ tar xzf redis-3.2.9.tar.gz $ cd redis-3.2.9 $ make $ src/redis-server $ src/redis-cli redis> set foo bar OK redis> get foo "bar" LINUX Kurulumsuz denemek için http://try.redis.io/ http://dogancan.net
  • 9. BENCHMARK $ docker run --name redis101 -d redis redis-server --appendonly yes Persistence 127.0.0.1:6379> redis-benchmark -q -n 100000 root@3b41d7b54345:/data# redis-benchmark -q -n 100000 PING_INLINE: 48402.71 requests per second PING_BULK: 48332.53 requests per second SET: 51072.52 requests per second GET: 52192.07 requests per second INCR: 52631.58 requests per second LPUSH: 51203.28 requests per second RPUSH: 53937.43 requests per second LPOP: 52328.62 requests per second RPOP: 53908.36 requests per second SADD: 52493.44 requests per second SPOP: 51020.41 requests per second LPUSH (needed to benchmark LRANGE): 53590.57 requests per second LRANGE_100 (first 100 elements): 26759.43 requests per second LRANGE_300 (first 300 elements): 12210.01 requests per second LRANGE_500 (first 450 elements): 7393.17 requests per second LRANGE_600 (first 600 elements): 7299.80 requests per second MSET (10 keys): 42589.44 requests per second root@9012bab64961:/# redis-benchmark -q -n 100000 PING_INLINE: 59523.81 requests per second PING_BULK: 57537.40 requests per second SET: 56179.78 requests per second GET: 59808.61 requests per second INCR: 60060.06 requests per second LPUSH: 58038.30 requests per second RPUSH: 59276.82 requests per second LPOP: 60975.61 requests per second RPOP: 57870.37 requests per second SADD: 59523.81 requests per second SPOP: 58445.36 requests per second LPUSH (needed to benchmark LRANGE): 58479.53 requests per second LRANGE_100 (first 100 elements): 35435.86 requests per second LRANGE_300 (first 300 elements): 17488.63 requests per second LRANGE_500 (first 450 elements): 12624.67 requests per second LRANGE_600 (first 600 elements): 10293.36 requests per second MSET (10 keys): 53447.35 requests per second Run the benchmark with the default configuration against 127.0.0.1:6379: $ redis-benchmark Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1: $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20 Fill 127.0.0.1:6379 with about 1 million keys only using the SET test: $ redis-benchmark -t set -n 1000000 -r 100000000 Benchmark 127.0.0.1:6379 for a few commands producing CSV output: $ redis-benchmark -t ping,set,get -n 100000 --csv Benchmark a specific command line: $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0 Fill a list with 10000 random elements: $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__ http://dogancan.net
  • 10. VERİ TİPLERİ × Strings × Lists × Hashes × Sets × Sorted sets × Geo APPEND BITCOUNT BITFIELD BITOP BITPOS DECR DECRBY GET GETBIT GETRANGE GETSET INCR INCRBY INCRBYFLOAT MGET MSET MSETNX PSETEX SET SETBIT SETEX SETNX SETRANGE STRLEN 127.0.0.1:6379> SET falan filan OK 127.0.0.1:6379> GET falan "filan" 127.0.0.1:6379> GET falan vesaire (error) ERR wrong number of arguments for 'get' command 127.0.0.1:6379> MGET falan vesaire 1) "filan" 2) (nil) 127.0.0.1:6379> INCR sayac (integer) 1 127.0.0.1:6379> INCR sayac (integer) 2 127.0.0.1:6379> GET sayac "2" 127.0.0.1:6379> INCRBY sayac 10 (integer) 12 127.0.0.1:6379> GET sayac “12" 127.0.0.1:6379> DECR sayac (integer) 11 127.0.0.1:6379> GET sayac “11" http://dogancan.net
  • 11. VERİ TİPLERİ - LISTS 127.0.0.1:6379> LPUSH 34duraklari "AVCILAR" (integer) 1 127.0.0.1:6379> LPUSH 34duraklari "INCIRLI" (integer) 2 127.0.0.1:6379> LINDEX 34duraklari 0 "INCIRLI" 127.0.0.1:6379> LINDEX 34duraklari 1 "AVCILAR" 127.0.0.1:6379> LPUSH 34duraklari ZINCIRLIKUYU (integer) 3 127.0.0.1:6379> LRANGE 34duraklari 0 3 1) "ZINCIRLIKUYU" 2) "INCIRLI" 3) "AVCILAR" 127.0.0.1:6379> LINSERT 34duraklari BEFORE "INCIRLI" "CEVIZLIBAG" (integer) 4 127.0.0.1:6379> LRANGE 34duraklari 0 3 1) "ZINCIRLIKUYU" 2) "CEVIZLIBAG" 3) "INCIRLI" 4) “AVCILAR" 127.0.0.1:6379> LPOP 34duraklari "ZINCIRLIKUYU" 127.0.0.1:6379> LRANGE 34duraklari 0 3 1) "CEVIZLIBAG" 2) "INCIRLI" 3) “AVCILAR" 127.0.0.1:6379> RPOP 34duraklari "AVCILAR" 127.0.0.1:6379> LRANGE 34duraklari 0 3 1) "CEVIZLIBAG" 2) "INCIRLI" BLPOP BRPOP BRPOPLPUSH LINDEX LINSERT LLEN LPOP LPUSH LPUSHX LRANGE LREM LSET LTRIM RPOP RPOPLPUSH RPUSH RPUSHX × Strings × Lists × Hashes × Sets × Sorted sets × Geo http://dogancan.net
  • 12. VERİ TİPLERİ - HASHES × Strings × Lists × Hashes × Sets × Sorted sets × Geo 127.0.0.1:6379> HSET user1 name Dogan (integer) 1 127.0.0.1:6379> HSET user1 surname Can (integer) 1 127.0.0.1:6379> HGETALL user1 1) "name" 2) "Dogan" 3) "surname" 4) "Can" 127.0.0.1:6379> HGET user1 name "Dogan" 127.0.0.1:6379> HGET user1 surname "Can" 127.0.0.1:6379> HSET user1 yas 38 (integer) 1 127.0.0.1:6379> HINCRBY user1 yas 1 (integer) 39 127.0.0.1:6379> HSET user3 name "Omer" surname "Can" (error) ERR wrong number of arguments for 'hset' command 127.0.0.1:6379> HMSET user3 name "Omer" surname "Can" OK 127.0.0.1:6379> HMGET user3 name 1) "Omer" 127.0.0.1:6379> HMGET user3 name surname yas 1) "Omer" 2) "Can" 3) (nil) HDEL HEXISTS HGET HGETALL HINCRBY HINCRBYFLOAT HKEYS HLEN HMGET HMSET HSCAN HSET HSETNX HSTRLEN HVALS http://dogancan.net
  • 13. VERİ TİPLERİ - SETS 127.0.0.1:6379> SADD 34 AVCILAR INCIRLI CEVIZLIBAG ZINCIRLIKUYU (integer) 4 127.0.0.1:6379> SMEMBERS 34 1) "CEVIZLIBAG" 2) "ZINCIRLIKUYU" 3) "INCIRLI" 4) "AVCILAR" 127.0.0.1:6379> SADD 34AS CEVIZLIBAG ZINCIRLIKUYU UNALAN KADIKOY (integer) 4 127.0.0.1:6379> SMEMBERS 34AS 1) "CEVIZLIBAG" 2) "KADIKOY" 3) "ZINCIRLIKUYU" 4) "UNALAN" 127.0.0.1:6379> SDIFF 34 34AS 1) "INCIRLI" 2) "AVCILAR" 127.0.0.1:6379> SDIFF 34AS 34 1) "KADIKOY" 2) "UNALAN" 127.0.0.1:6379> SDIFFSTORE ortakduraklar 34 34AS SADD SCARD SDIFF SDIFFSTORE SINTER SINTERSTORE SISMEMBER SMEMBERS SMOVE SPOP SRANDMEMBER SREM SSCAN SUNION SUNIONSTORE × Strings × Lists × Hashes × Sets × Sorted sets × Geo http://dogancan.net
  • 14. VERİ TİPLERİ - GEO × Strings × Lists × Hashes × Sets × Sorted sets × Geo { "06:00": { "TA001": { "lat": "40.93486", "lng": "29.141796" }, "O3059": { "lat": "41.001045", "lng": "29.077938" }, "K1700": { "lat": "40.978718", "lng": "29.237024" }, "M2523": { "lat": "41.05971", "lng": "28.790985" }, "K1763": { "lat": "41.06437", "lng": "28.95947" }, "M3016": { "lat": "41.06643", "lng": "29.012556" } }, GEOADD GEODIST GEOHASH GEOPOS GEORADIUS GEORADIUSBYMEMBER 127.0.0.1:6379> GEOPOS saat:06:00 TA001 1) 1) "29.14179593324661255" 2) “40.93486083827887256" 127.0.0.1:6379> GEODIST saat:06:00 TA001 M3016 km "18.2167" 127.0.0.1:6379> GEORADIUSBYMEMBER saat:06:00 TA001 10 km 1) "TA001" 2) "O3059" 3) "K1700" 127.0.0.1:6379> GEORADIUSBYMEMBER saat:06:00 TA001 100 km 1) "M2523" 2) "TA001" 3) "O3059" 4) "K1763" 5) "M3016" 6) "K1700" 127.0.0.1:6379> GEOHASH saat:06:00 TA001 1) "sxk8z5uqv50" 127.0.0.1:6379> GEORADIUS saat:06:00 28.980 41.0673 10 km WITHCOORD WITHDIST 1) 1) "K1763" 2) "1.7522" 3) 1) "28.95947009325027466" 2) "41.06436988119413201" 2) 1) "M3016" 2) "2.7318" 3) 1) "29.01255637407302856" 2) "41.06643060949667756" 19 $jsonstr = file_get_contents("data.json"); 20 $arr = json_decode($jsonstr); 21 foreach ($arr as $saat=>$bus) { 22 foreach ($bus as $kapino=>$latlng) { 23 # GEOADD saat:06:00 29.141796 40.93486 TA001 24 $client->geoadd("saat:".$saat,$latlng->lng, $latlng->lat, $kapino); 25 } 26 } http://geohash.org/sxk8z5uqv50 http://dogancan.net
  • 15. ÖRNEK - REPLICATION $ docker run --name redis-master -p 6000:6379 -d redis redis-server --appendonly yes $ docker run --name redis-slave1 -p 6001:6379 -d redis redis-server --appendonly yes $ docker exec redis-slave1 redis-cli slaveof 192.168.99.100 6000 $ docker exec redis-slave2 redis-cli slaveof 192.168.99.100 6000 $ docker run --name redis-slave2 -p 6002:6379 -d redis redis-server --appendonly yes 1 <?php 2 #  client.php 3 4 require "/vendor/autoload.php"; 5 6 $client = new PredisClient([ 7 'scheme' => 'tcp', 8 'host' => '192.168.99.100', 9 'port' => 6000, 10 ]); 11 12 $status = $client->set("user1", "Dogan Can"); 13 echo "SET sonucu:".$status; 14 echo "n"; 15 16 $result = $client->get("user1"); 17 echo "GET sonucu:n"; 18 var_dump($result); $ composer require predis/predis $ php clients.php Php Uygulaması Docker container ayarı $ docker run --name redis-master -p 6000:6379 -e REDIS_REPLICATION_MODE=master -e REDIS_PASSWORD=masterp -d bitnami/redis:latest $ docker run --name redis-slave -p 6001:6379 -e REDIS_REPLICATION_MODE=slave -e REDIS_MASTER_HOST=10.100.2.205 -e REDIS_MASTER_PORT=6000 -e REDIS_MASTER_PASSWORD=masterp -e REDIS_PASSWORD=p -d bitnami/redis:latest http://dogancan.net
  • 16. PUB/SUB PSUBSCRIBE PUBLISH PUBSUB PUNSUBSCRIBE SUBSCRIBE UNSUBSCRIBE 1 <?php 2 # pub.php 3 4 include __DIR__ . "/vendor/autoload.php"; 5 6 $client = new PredisClient([ 7 'scheme' => 'tcp', 8 'host' => '192.168.99.100', 9 'port' => 6000, 10 ]); 11 12 $durak = $client->lpop("34"); 13 14 $client->publish('34', $durak.' duragindan gecti'); 1 <?<php 2 // Ilgili socket surekli dinleniyor 3 ini_set("default_socket_timeout", -1); 4 5 require "vendor/autoload.php"; 6 7 $client = new PredisClient([ 8 'scheme' => 'tcp', 9 'host' => '192.168.99.100', 10 'port' => 6000, 11 ]); 12 13 $consumer = new PredisPubSubConsumer($client); 14 15 $loop = new PredisPubSubDispatcherLoop($consumer); 16 17 $loop->attachCallback('34', 'show'); 18 $loop->run(); 19 20 function show($data) { 21 static $i = 0; 22 echo ++$i . '.' . $data . PHP_EOL; 23 } http://dogancan.net
  • 17. rename-command FLUSHDB "" rename-command FLUSHALL "" BAZI ÖZEL DURUMLAR http://dogancan.net
  • 18. ./webdis & curl http://127.0.0.1:7379/SET/hello/world → {"SET":[true,"OK"]} curl http://127.0.0.1:7379/GET/hello → {"GET":"world"} curl -d "GET/hello" http://127.0.0.1:7379/ → {"GET":"world"} EKSTRA : WEBDİS http://dogancan.net