Mais conteúdo relacionado Semelhante a Redis for the Everyday Developer (20) Redis for the Everyday Developer11. • Created by Salvatore Sanfilippo ( @antirez )
• Sponsored by VMware
• 4 years old
• redis.io
25. Replication
Pub/Sub
Transactions
Scripting
Slices
Dices
Makes julienne fries
53. Search...
omg cheezburgers in the lunchroom
today. Better hurry if u want 1!!! ^_^
How do I store this?
55. key value
homepage_message omg cheezburgers...
56. key value
homepage_message omg cheezburgers...
tps_reports new cover pages on...
68. redis-benchmark
====== INCR ======
10000 requests completed in 0.08 seconds
50 parallel clients
3 bytes payload
keep alive: 1
100.00% <= 0 milliseconds
119047.62 requests per second
77. Generic
Hash // strings and numbers
List $redis['ross:mood'] = "happy";
Set $redis['foo'] = 9;
Sorted Set
78. Generic
Hash // associative array
List $redis['foo']['name'] = 'Bob';
$redis['foo']['age'] = 31;
Set
Sorted Set
Objects, forms, records
79. Generic
Hash // not associative
List $redis['foo'][] = 'zip';
Set $redis['foo'][] = 'zap';
Sorted Set
Lists, stacks, queues
80. Generic
// No dupes, no order
Hash
shuffle(
List
array_unique($redis['foo'])
Set );
Sorted Set
Relations, stats, matching
81. Generic
Hash // Ordered by *score*
List array_unique($redis['foo']);
Set
Sorted Set
Curing cancer, world peace
Sets but with order or scores
82. Y U NO STOP
LISTING THINGS
86. // 2 hours later...
$client->lpush('news:latest', 'Takei 2016');
// Redis
['Takei 2016', 'Aliens Attack!']
108. SELECT * FROM Articles
INNER JOIN Authors ON (complicated joins)
-- More joins
WHERE (complicated logic)
LIMIT 0, 20
109. SELECT Articles.id FROM Articles
INNER JOIN Authors ON (complicated joins)
-- More joins
WHERE (complicated logic)
112. SELECT * FROM Articles
INNER JOIN Authors ON (complicated joins)
-- More joins
WHERE Articles.id IN (1, 2, 3)
145. PHP
Redis
Node.js Python
146. • ActionScript • Java
• C • Lua
• C# • Node.js
• C++ • Objective-C
• Clojure • Perl
• Common Lisp • PHP
• Erlang • Pure Data
• Fancy • Python
• Go • Ruby
• Haskell • Scala
• haXe • Smalltalk
• Io • Tcl
148. var redis = require("redis");
var client = redis.createClient();
client.get("foo", redis.print);
158. // worker
$client = new PredisClient(array(
'read_write_timeout' => -1
));
do {
$job = $client->brpop('jobs:pending', 0);
doJob($job);
} while(true);
166. do {
$job = $client->brpop('jobs:pending', 0);
doJob($job);
} while(true);
171. do {
$job = $client->brpoplpush(
'jobs:pending', 'jobs:working', 0
);
doJob($job);
} while(true);
172. do {
$job = $client->brpoplpush(
'jobs:pending', 'jobs:working', 0
);
if(doJob($job)) {
$client->lrem('jobs:working', 0, $job);
}
} while(true);
177. var arguments
local first = redis.call('get', KEYS[1]);
local second = redis.call('get', KEYS[2]);
redis.call('set', KEYS[1], second);
redis.call('set', KEYS[2], first);
return {first, second};
178. // jesse: dude
// chester: sweet
EVAL 'local first...' 2 jesse chester
// jesse: sweet
// chester: dude
179. Eval != Evil
*Offer only applies
in Redis-Land.
.
Void where pedantic
195. IAEA Kotaku
@svdgraaf
Alltheragefaces
QuickMeme