Talk presented at Malaysian Open Source Conference 2012 (09-07-12) :
Using the right tools for the right job. Yeah right! So what is your problem? Your farmville-like online games empire gaining momentum as what you never dream of? Your data read and write is close to maximum which make options like write through cache or other common scaling agendas less fun and not really effective? You’re getting tired of traditional RDBMS and all the bru-ha-ha over oldSQL, NoSQL and NewSQL? Redis might address (some) of your problems. It works with an in-memory dataset as an advanced key-value store often referred as data structure server that can runs multiple atomic operations. This session will uncover the beauty and practicality of Redis and how it works with most languages especially PHP.
12. Redis
REmote Dictionary Server
Advanced Key-value store
Disk backed In-memory database (with virt
mem)
High write throughput (30-150k ops/sec)
Data structures (list, hashes, sets, atomic
ops)
13. Redis, unique?
Simple, lightweight
In memory (RAM).. Fast, fast, fast (very!)
Disk-backed, background writes
Master-slave config.
Multi language support
30. Lists
List of Strings
Max length of a list is 232 - 1 elements
(4294967295, more than 4 billion of
elements per list).
31. Sets
Collection of Strings (unordered)
Support a number of server side commands
to compute sets
Max number of members in a set is 232 - 1
(4294967295, more than 4 billion of
members per set).
39. PHP : Hashes
redis>hmset firsthash a "1“ b “2“ c "3“ d "4“
OK
redis>hget firsthash c
"3“
redis>hset firsthash e "5“
(integer) 1
redis>hget firsthash e
"5“
redis>hget firsthash d
"4"
40. PHP : Hashes
<?php
$redis = new Redis();
$redis->connect('127.0.0.1',6379);
$redis->delete('user:1');
$redis->hmset('user:1',
array('name'=>„Zack','salary'=>3000));
//Give Zack a $200 Raise:
$redis->hincrby('user:1','salary',200);