Code Times

Things that happen in the life of a developer in charge of a big high-traffic website and tries to survive.

Mod_Redis for Apache







Thanks to Redis Google Group I’ve fallen in this link while browsing the web: https://github.com/sneakybeaky/mod_redis

It’s an Apache module providing an interface to Redis servers. This means that you can access different URLs to set or get values from Redis, avoiding all the overhead PHP, the PHP Redis extension and probably your framework are putting in.

By using different HTTP methods (POST, PUT, DELETE, GET), you can set keys and retrieve keys in a very customizable way.

By default the module returns an XML representation of the resulting Redis response. For example configuring a RedisAlias to support the PING command:

(RedisAlias ^ping$ "PING")

the response would be:

<?xml version="1.0" encoding="UTF-8"?> <response> <status>PONG</status></response> 

This behavior can be altered by appending .json to the url, for example:

{ "status" : "PONG" } 

Alternatively, appending .jsonp and adding a query parameter ‘callback’ respond with:

callback({ "status" : "PONG" });

The Mod_Redis module can be useful to load different values in asynchronous requests after the page has been loaded, for example you can dynamically refresh the viewcounts in the player page every 30 seconds with an Ajax call that will not affect your webserver, or to refresh the number of comments a video had.

There’s also a Nginx module providing the same features in https://github.com/agentzh/redis2-nginx-module

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • Google Buzz
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>