SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
Better NoSQL
Economic transaction stored on
  Tablet from Mesopotamia
Economic transactions stored in
  relational “way” - e.g. table
Why NoSQL
"I think the primary lesson the Postgres
community can learn from NoSQL is that not
everyone needs all our features, and if it can
be easily accomplished, we should allow
users to trade features for some of the
NoSQL desired behaviors.“

Bruce Momjian
(author of PostgreSQL)
Redis
Why NoSQL
Memory is the new disk, disk is the new
tape.

Jim Gray
Storage comparison
Why NoSQL
If you're deployng memcache on top of your
database, you're inventing your own ad-hoc,
difficult to maintain NoSQL data store

Ian Eure
So what is Redis?
Key/value data store, similar to Memcached

Developed by
 ● Salvatore Sanfilippo and
 ● Pieter Noordhuis

More then any other NoSQL
 ● Persistance
 ● Replication
 ● More data types
More info at:
 ● http://redis.io/
So what is Redis?
] SET USER1 Niki
OK
] GET USER1
Niki
] SADD ALL 1
OK
] SADD ALL 5
OK
SMEMBERS ALL
1
5
So what is Redis?
] INCR A
1
] INCRBY A 2
3
] GET A
3
Client Libraries
ActionScript C C# C++

Clojure Lisp Erlang Go Haskell
Java Lua Node.js Objective-C

Perl PHP Pyhon Ruby Scala

Smalltalk TCL
Blazing fast
about 110,000 SETs per second,
about 81,000 GETs per second.

http://redis.io/topics/benchmarks
SQL cache
$r = new Redis();
$r->connect("127.0.0.1", "6379");

$id = (int) $_REQUEST["id"];
$sql = "select * from users where id = $id";

// Create a hash key
$key = "sql_cache:" . md5($sql);

// Check if data is in cache.
if ($data = @unseralize( $r->get($key) ) === false){
$data = exec_db_query($sql);
// Put data into cache for 1 hour
$r->set($key, serialize($data) );
$r->expires($key, 3600);
}

display_data($data);
IP restriction
// First of all, check if the IP address is member of trusted set...
if ( ! $r->sismember("trusted:all", $_SERVER["REMOTE_ADDR"]) ){
// Create a hash key
$key = "ip:" . $_SERVER["REMOTE_ADDR"];
// Increase the hit counter
$hits = $r->incr($key);
$r->expires($key, 3600);
// Check if this IP had more than 1000 visits for 1 hour...
if ($hits > 1000){
// Something fishy going on, redirect...
header("location: page_with_capcha.php");
exit;
}
}

// Web page continue here...
// ...
Random news
$newsroom = "sport";
$key = "news:" . $newsroom;

//Get random item...
$item = $r->lindex($key, rand(0, $r->llen
($key) - 1));

echo $item;
Processing queue
for($i = 0; $i < 1000; $i++){
$x = $r->incr("id:work");

$r->hmset(
"work:$x", array(
"id" => $i ,
"a" => rand() ,
"b" => rand()
)
);

$r->sadd("pool:work", $x);
}

echo "Work distributedn";
Processing queue #2
while(true){
// Get random work id...
$x = $r->spop("pool:work");

if ($x === false){
echo "No more work to don";
sleep(10);
continue;
}

// Get work description...
$data = $r->hgetall("work:$x");

if (!count($data))
continue;

// Do the work...
$total = $data["a"] + $data["b"];

// Store back...
$r->hset("work:$x", "total", $total);

// And store id in finished pool...
$r->sadd("pool:finishedwork", $x);

echo "Work #$x is finished...n";
// sleep(2);
}
Locks
$team_name = "Blue team";

$user = "john";

$key = "lock:" . $team_name;

// Try to get the lock...
// e.g. set the key only if not exists...
if ($r->setnx($key), $user){
// Because system can crash, give him 5 min.
$r->expire($key, 60 * 5);

update_the_info();

// Release the lock...
$r->del($key);
}else{
echo "Warning! User " . $r->get($key) . " updating the information at the moment. Try again later :)";
}
Database design
http://redis4you.com/articles.php?id=009
Try Redis 4 Free

http://redis4you.com/
Questions?

nmmm(at)nmmm.nu
skype: nmmmnu

Mais conteúdo relacionado

Mais procurados

Pm 4.0 permission_storage
Pm 4.0 permission_storagePm 4.0 permission_storage
Pm 4.0 permission_storageOleg K
 
PostgreSQLからMongoDBへ
PostgreSQLからMongoDBへPostgreSQLからMongoDBへ
PostgreSQLからMongoDBへBasuke Suzuki
 
Format xls sheets Demo Mode
Format xls sheets Demo ModeFormat xls sheets Demo Mode
Format xls sheets Demo ModeJared Bourne
 
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green CloudRyousei Takano
 
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet Camp Amsterdam 2015: Manifests of Future PastPuppet Camp Amsterdam 2015: Manifests of Future Past
Puppet Camp Amsterdam 2015: Manifests of Future PastPuppet
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency InjectionRifat Nabi
 
Persistencia de datos con Parse
Persistencia de datos con ParsePersistencia de datos con Parse
Persistencia de datos con ParseAlfonso Alba
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤Takahiro Inoue
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDBTakahiro Inoue
 
"You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics""You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics"ITCP Community
 
iOS: Using persistant storage
iOS: Using persistant storageiOS: Using persistant storage
iOS: Using persistant storageJussi Pohjolainen
 
Being! Black Hat with Drupal - Anand Toshniwal
Being! Black Hat with Drupal - Anand ToshniwalBeing! Black Hat with Drupal - Anand Toshniwal
Being! Black Hat with Drupal - Anand ToshniwalDrupalMumbai
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2Takahiro Inoue
 
Solr integration in Magento Enterprise
Solr integration in Magento EnterpriseSolr integration in Magento Enterprise
Solr integration in Magento EnterpriseTobias Zander
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday DeveloperRoss Tuck
 

Mais procurados (20)

Pm 4.0 permission_storage
Pm 4.0 permission_storagePm 4.0 permission_storage
Pm 4.0 permission_storage
 
Hive jdbc
Hive jdbcHive jdbc
Hive jdbc
 
Tricks
TricksTricks
Tricks
 
PostgreSQLからMongoDBへ
PostgreSQLからMongoDBへPostgreSQLからMongoDBへ
PostgreSQLからMongoDBへ
 
Format xls sheets Demo Mode
Format xls sheets Demo ModeFormat xls sheets Demo Mode
Format xls sheets Demo Mode
 
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
 
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet Camp Amsterdam 2015: Manifests of Future PastPuppet Camp Amsterdam 2015: Manifests of Future Past
Puppet Camp Amsterdam 2015: Manifests of Future Past
 
Litebox
LiteboxLitebox
Litebox
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Persistencia de datos con Parse
Persistencia de datos con ParsePersistencia de datos con Parse
Persistencia de datos con Parse
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDB
 
"You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics""You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics"
 
Indexing
IndexingIndexing
Indexing
 
iOS: Using persistant storage
iOS: Using persistant storageiOS: Using persistant storage
iOS: Using persistant storage
 
Being! Black Hat with Drupal - Anand Toshniwal
Being! Black Hat with Drupal - Anand ToshniwalBeing! Black Hat with Drupal - Anand Toshniwal
Being! Black Hat with Drupal - Anand Toshniwal
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
 
Mongodb workshop
Mongodb workshopMongodb workshop
Mongodb workshop
 
Solr integration in Magento Enterprise
Solr integration in Magento EnterpriseSolr integration in Magento Enterprise
Solr integration in Magento Enterprise
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday Developer
 

Destaque

Lengua anuncio
Lengua anuncioLengua anuncio
Lengua anunciofranky226
 
Tausug beliefs and practices
Tausug beliefs and practicesTausug beliefs and practices
Tausug beliefs and practicesSamantha Jumawan
 
Hum2220 sp2015 syllabus
Hum2220 sp2015 syllabusHum2220 sp2015 syllabus
Hum2220 sp2015 syllabusProfWillAdams
 
2007 Spring Newsletter
2007 Spring Newsletter2007 Spring Newsletter
2007 Spring NewsletterDirect Relief
 
2015 2016 hss speakers
2015 2016 hss speakers2015 2016 hss speakers
2015 2016 hss speakersProfWillAdams
 
гарчиггүй 1
гарчиггүй 1гарчиггүй 1
гарчиггүй 1mongoo_8301
 
Hum1020 sp2015 syllabus
Hum1020 sp2015 syllabusHum1020 sp2015 syllabus
Hum1020 sp2015 syllabusProfWillAdams
 
Hum2310 fa2014 exam 4 study guide
Hum2310 fa2014 exam 4 study guideHum2310 fa2014 exam 4 study guide
Hum2310 fa2014 exam 4 study guideProfWillAdams
 
Arh1000 sp2016 syllabus
Arh1000 sp2016 syllabusArh1000 sp2016 syllabus
Arh1000 sp2016 syllabusProfWillAdams
 
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...Ñûrãzwã Šãlěh
 
Tsunami response six months later
Tsunami response six months laterTsunami response six months later
Tsunami response six months laterDirect Relief
 
Presentazione cantinando per aziende
Presentazione cantinando per aziendePresentazione cantinando per aziende
Presentazione cantinando per aziendeDaniel Romano
 
상상지니릴레이 Wmc
상상지니릴레이 Wmc상상지니릴레이 Wmc
상상지니릴레이 WmcHaNee Seo
 
How to suck at presenting (and how to avoid it)
How to suck at presenting (and how to avoid it)How to suck at presenting (and how to avoid it)
How to suck at presenting (and how to avoid it)Steve Talks
 

Destaque (20)

Lengua anuncio
Lengua anuncioLengua anuncio
Lengua anuncio
 
Turkey
TurkeyTurkey
Turkey
 
Tausug beliefs and practices
Tausug beliefs and practicesTausug beliefs and practices
Tausug beliefs and practices
 
Hum2220 sp2015 syllabus
Hum2220 sp2015 syllabusHum2220 sp2015 syllabus
Hum2220 sp2015 syllabus
 
Websurvey
WebsurveyWebsurvey
Websurvey
 
2011 Year in Review
2011 Year in Review2011 Year in Review
2011 Year in Review
 
2006 annual report
2006 annual report2006 annual report
2006 annual report
 
2007 Spring Newsletter
2007 Spring Newsletter2007 Spring Newsletter
2007 Spring Newsletter
 
2015 2016 hss speakers
2015 2016 hss speakers2015 2016 hss speakers
2015 2016 hss speakers
 
MomentReel
MomentReelMomentReel
MomentReel
 
гарчиггүй 1
гарчиггүй 1гарчиггүй 1
гарчиггүй 1
 
Hum1020 sp2015 syllabus
Hum1020 sp2015 syllabusHum1020 sp2015 syllabus
Hum1020 sp2015 syllabus
 
Hum2310 fa2014 exam 4 study guide
Hum2310 fa2014 exam 4 study guideHum2310 fa2014 exam 4 study guide
Hum2310 fa2014 exam 4 study guide
 
Arh1000 sp2016 syllabus
Arh1000 sp2016 syllabusArh1000 sp2016 syllabus
Arh1000 sp2016 syllabus
 
Autismo
AutismoAutismo
Autismo
 
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
 
Tsunami response six months later
Tsunami response six months laterTsunami response six months later
Tsunami response six months later
 
Presentazione cantinando per aziende
Presentazione cantinando per aziendePresentazione cantinando per aziende
Presentazione cantinando per aziende
 
상상지니릴레이 Wmc
상상지니릴레이 Wmc상상지니릴레이 Wmc
상상지니릴레이 Wmc
 
How to suck at presenting (and how to avoid it)
How to suck at presenting (and how to avoid it)How to suck at presenting (and how to avoid it)
How to suck at presenting (and how to avoid it)
 

Semelhante a Redis the better NoSQL

Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redisjimbojsb
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
All Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for NewbiesAll Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for NewbiesDave Stokes
 
Nosql hands on handout 04
Nosql hands on handout 04Nosql hands on handout 04
Nosql hands on handout 04Krishna Sankar
 
Use Your MySQL Knowledge to Become a MongoDB Guru
Use Your MySQL Knowledge to Become a MongoDB GuruUse Your MySQL Knowledge to Become a MongoDB Guru
Use Your MySQL Knowledge to Become a MongoDB GuruTim Callaghan
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistenceHugo Hamon
 
PHP CLI: A Cinderella Story
PHP CLI: A Cinderella StoryPHP CLI: A Cinderella Story
PHP CLI: A Cinderella StoryMike Lively
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)Johannes Hoppe
 
Drupal II: The SQL
Drupal II: The SQLDrupal II: The SQL
Drupal II: The SQLddiers
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data ObjectsWez Furlong
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourPeter Friese
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in PerlLaurent Dami
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 

Semelhante a Redis the better NoSQL (20)

Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redis
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
veracruz
veracruzveracruz
veracruz
 
veracruz
veracruzveracruz
veracruz
 
veracruz
veracruzveracruz
veracruz
 
veracruz
veracruzveracruz
veracruz
 
All Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for NewbiesAll Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for Newbies
 
Fatc
FatcFatc
Fatc
 
Nosql hands on handout 04
Nosql hands on handout 04Nosql hands on handout 04
Nosql hands on handout 04
 
Use Your MySQL Knowledge to Become a MongoDB Guru
Use Your MySQL Knowledge to Become a MongoDB GuruUse Your MySQL Knowledge to Become a MongoDB Guru
Use Your MySQL Knowledge to Become a MongoDB Guru
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
PHP CLI: A Cinderella Story
PHP CLI: A Cinderella StoryPHP CLI: A Cinderella Story
PHP CLI: A Cinderella Story
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
 
Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09
 
Drupal II: The SQL
Drupal II: The SQLDrupal II: The SQL
Drupal II: The SQL
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 

Mais de OpenFest team

Embedding FreeBSD: for large and small beds
Embedding FreeBSD: for large and small bedsEmbedding FreeBSD: for large and small beds
Embedding FreeBSD: for large and small bedsOpenFest team
 
Why you can charge for open source software
Why you can charge for open source softwareWhy you can charge for open source software
Why you can charge for open source softwareOpenFest team
 
Microinvest Warehouse Open
Microinvest Warehouse OpenMicroinvest Warehouse Open
Microinvest Warehouse OpenOpenFest team
 
Как да правим по-добър бизнес с услуги около софтуера с отворен код
Как да правим по-добър бизнес с услуги около софтуера с отворен кодКак да правим по-добър бизнес с услуги около софтуера с отворен код
Как да правим по-добър бизнес с услуги около софтуера с отворен кодOpenFest team
 
Електронни пари: Пътят до BitCoin и поглед напред
Електронни пари: Пътят до BitCoin и поглед напредЕлектронни пари: Пътят до BitCoin и поглед напред
Електронни пари: Пътят до BitCoin и поглед напредOpenFest team
 
Виртуализирано видеонаблюдение под FreeBSD
Виртуализирано видеонаблюдение под FreeBSDВиртуализирано видеонаблюдение под FreeBSD
Виртуализирано видеонаблюдение под FreeBSDOpenFest team
 
RFID технологии и проблеми със сигурността им
RFID технологии и проблеми със сигурността имRFID технологии и проблеми със сигурността им
RFID технологии и проблеми със сигурността имOpenFest team
 
Свободни PLC
Свободни PLCСвободни PLC
Свободни PLCOpenFest team
 
Distributed WPA PSK security audit
Distributed WPA PSK security auditDistributed WPA PSK security audit
Distributed WPA PSK security auditOpenFest team
 
Why kernelspace sucks?
Why kernelspace sucks?Why kernelspace sucks?
Why kernelspace sucks?OpenFest team
 
Направи си сам суперкомпютър
Направи си сам суперкомпютърНаправи си сам суперкомпютър
Направи си сам суперкомпютърOpenFest team
 
Свободни курсове за обучение
Свободни курсове за обучениеСвободни курсове за обучение
Свободни курсове за обучениеOpenFest team
 
Using Open Source technologies to create Enterprise Level Cloud System
Using Open Source technologies to create Enterprise Level Cloud SystemUsing Open Source technologies to create Enterprise Level Cloud System
Using Open Source technologies to create Enterprise Level Cloud SystemOpenFest team
 
Behaviour-Driven Development, Ruby Style
Behaviour-Driven Development, Ruby StyleBehaviour-Driven Development, Ruby Style
Behaviour-Driven Development, Ruby StyleOpenFest team
 

Mais de OpenFest team (20)

Embedding FreeBSD: for large and small beds
Embedding FreeBSD: for large and small bedsEmbedding FreeBSD: for large and small beds
Embedding FreeBSD: for large and small beds
 
Why you can charge for open source software
Why you can charge for open source softwareWhy you can charge for open source software
Why you can charge for open source software
 
Microinvest Warehouse Open
Microinvest Warehouse OpenMicroinvest Warehouse Open
Microinvest Warehouse Open
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Как да правим по-добър бизнес с услуги около софтуера с отворен код
Как да правим по-добър бизнес с услуги около софтуера с отворен кодКак да правим по-добър бизнес с услуги около софтуера с отворен код
Как да правим по-добър бизнес с услуги около софтуера с отворен код
 
Pf sense 2.0
Pf sense 2.0Pf sense 2.0
Pf sense 2.0
 
Електронни пари: Пътят до BitCoin и поглед напред
Електронни пари: Пътят до BitCoin и поглед напредЕлектронни пари: Пътят до BitCoin и поглед напред
Електронни пари: Пътят до BitCoin и поглед напред
 
Node.social
Node.socialNode.social
Node.social
 
Виртуализирано видеонаблюдение под FreeBSD
Виртуализирано видеонаблюдение под FreeBSDВиртуализирано видеонаблюдение под FreeBSD
Виртуализирано видеонаблюдение под FreeBSD
 
RFID технологии и проблеми със сигурността им
RFID технологии и проблеми със сигурността имRFID технологии и проблеми със сигурността им
RFID технологии и проблеми със сигурността им
 
initLab
initLabinitLab
initLab
 
Свободни PLC
Свободни PLCСвободни PLC
Свободни PLC
 
Distributed WPA PSK security audit
Distributed WPA PSK security auditDistributed WPA PSK security audit
Distributed WPA PSK security audit
 
Aesaes
AesaesAesaes
Aesaes
 
Why kernelspace sucks?
Why kernelspace sucks?Why kernelspace sucks?
Why kernelspace sucks?
 
Направи си сам суперкомпютър
Направи си сам суперкомпютърНаправи си сам суперкомпютър
Направи си сам суперкомпютър
 
Свободни курсове за обучение
Свободни курсове за обучениеСвободни курсове за обучение
Свободни курсове за обучение
 
Using Open Source technologies to create Enterprise Level Cloud System
Using Open Source technologies to create Enterprise Level Cloud SystemUsing Open Source technologies to create Enterprise Level Cloud System
Using Open Source technologies to create Enterprise Level Cloud System
 
Emacs reborn
Emacs rebornEmacs reborn
Emacs reborn
 
Behaviour-Driven Development, Ruby Style
Behaviour-Driven Development, Ruby StyleBehaviour-Driven Development, Ruby Style
Behaviour-Driven Development, Ruby Style
 

Último

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 

Último (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 

Redis the better NoSQL

  • 2. Economic transaction stored on Tablet from Mesopotamia
  • 3.
  • 4.
  • 5. Economic transactions stored in relational “way” - e.g. table
  • 6. Why NoSQL "I think the primary lesson the Postgres community can learn from NoSQL is that not everyone needs all our features, and if it can be easily accomplished, we should allow users to trade features for some of the NoSQL desired behaviors.“ Bruce Momjian (author of PostgreSQL)
  • 8. Why NoSQL Memory is the new disk, disk is the new tape. Jim Gray
  • 10. Why NoSQL If you're deployng memcache on top of your database, you're inventing your own ad-hoc, difficult to maintain NoSQL data store Ian Eure
  • 11. So what is Redis? Key/value data store, similar to Memcached Developed by ● Salvatore Sanfilippo and ● Pieter Noordhuis More then any other NoSQL ● Persistance ● Replication ● More data types More info at: ● http://redis.io/
  • 12.
  • 13. So what is Redis? ] SET USER1 Niki OK ] GET USER1 Niki ] SADD ALL 1 OK ] SADD ALL 5 OK SMEMBERS ALL 1 5
  • 14. So what is Redis? ] INCR A 1 ] INCRBY A 2 3 ] GET A 3
  • 15. Client Libraries ActionScript C C# C++ Clojure Lisp Erlang Go Haskell Java Lua Node.js Objective-C Perl PHP Pyhon Ruby Scala Smalltalk TCL
  • 16. Blazing fast about 110,000 SETs per second, about 81,000 GETs per second. http://redis.io/topics/benchmarks
  • 17. SQL cache $r = new Redis(); $r->connect("127.0.0.1", "6379"); $id = (int) $_REQUEST["id"]; $sql = "select * from users where id = $id"; // Create a hash key $key = "sql_cache:" . md5($sql); // Check if data is in cache. if ($data = @unseralize( $r->get($key) ) === false){ $data = exec_db_query($sql); // Put data into cache for 1 hour $r->set($key, serialize($data) ); $r->expires($key, 3600); } display_data($data);
  • 18. IP restriction // First of all, check if the IP address is member of trusted set... if ( ! $r->sismember("trusted:all", $_SERVER["REMOTE_ADDR"]) ){ // Create a hash key $key = "ip:" . $_SERVER["REMOTE_ADDR"]; // Increase the hit counter $hits = $r->incr($key); $r->expires($key, 3600); // Check if this IP had more than 1000 visits for 1 hour... if ($hits > 1000){ // Something fishy going on, redirect... header("location: page_with_capcha.php"); exit; } } // Web page continue here... // ...
  • 19. Random news $newsroom = "sport"; $key = "news:" . $newsroom; //Get random item... $item = $r->lindex($key, rand(0, $r->llen ($key) - 1)); echo $item;
  • 20. Processing queue for($i = 0; $i < 1000; $i++){ $x = $r->incr("id:work"); $r->hmset( "work:$x", array( "id" => $i , "a" => rand() , "b" => rand() ) ); $r->sadd("pool:work", $x); } echo "Work distributedn";
  • 21. Processing queue #2 while(true){ // Get random work id... $x = $r->spop("pool:work"); if ($x === false){ echo "No more work to don"; sleep(10); continue; } // Get work description... $data = $r->hgetall("work:$x"); if (!count($data)) continue; // Do the work... $total = $data["a"] + $data["b"]; // Store back... $r->hset("work:$x", "total", $total); // And store id in finished pool... $r->sadd("pool:finishedwork", $x); echo "Work #$x is finished...n"; // sleep(2); }
  • 22. Locks $team_name = "Blue team"; $user = "john"; $key = "lock:" . $team_name; // Try to get the lock... // e.g. set the key only if not exists... if ($r->setnx($key), $user){ // Because system can crash, give him 5 min. $r->expire($key, 60 * 5); update_the_info(); // Release the lock... $r->del($key); }else{ echo "Warning! User " . $r->get($key) . " updating the information at the moment. Try again later :)"; }
  • 24. Try Redis 4 Free http://redis4you.com/