Monday, June 27, 2011

Redis in PHP Memory Cacher

New storage in PHP Memory Cacher: Redis
It's fast and stable.

Why Redis?
Because it's as fast as APC, data is accessible from php-cli and from mod_php (same as with using memcache), and all data are backed up on disk.
Last thing is very important - currently I store user's sessions in Redis and I don't afraid anymore to reboot my server.
Actually, backing up data on disk turns Redis from usual key-value storage to the BEST storage for data.

Why we love APC, Memcache as a key-value storages? Because they work fast. Especially APC.
What is their weak side? It's volatile storages because all data is stored in RAM only and RAM can be flushed easily. It's significant minus.
And Redis gives us pretty fast key-value storage (much faster than memcache) without that minus!

Even more: Redis has built-in abilities to work with lists, hashes, sets, even Pub/Sub channels. And it's not only "get/set" features, it's very useful and powerful features. So Redis can be used not only as a very fast key-value storage (even for canonical data), but as a database. We can work with data in different ways.

It's impresses me so much, my imagination is full of thoughts, how I can optimize data handling by using Redis - I'm going to write some kind of wrapper or ORM (don't know yet) in PHP to use Redis as database in my code. I use it already as a key-value cacher, but I want to move some data-algorithms from MySQL to Redis. I like MySQL (and SQL at all), but I know I can improve performance with Redis.

And already now you can check, how fast Redis works in my PHP Memory Cacher class :)

No comments:

Post a Comment