Return to Snippet

Revision: 45483
at May 2, 2011 07:39 by archangel


Initial Code
<?php
    define('R_HOST', "127.0.0.1");
    define('R_PORT', 6379);
    define('R_DATA', "3");
    define('R_PASS', ""); # Leave blank for none
    
    if(class_exists('Redis')) { # We have php-redis installed, and its faster than Predis
        $redis = new Redis();
	$redis->connect(R_HOST, R_PORT, 2.5);
        if(R_PASS)
            $redis->auth(R_PASS);
	$redis->select(R_DATA);
    } else {
        require './Predis/Predis.php';
        $redis = new Predis_Client(array(
            'host'      => R_HOST,
            'port'      => R_POST,
            'database'  => R_DATA,
            'password'  => R_PASS
	));
    }
?>

Initial URL


Initial Description
Will try and connect via php-redis, and will fall back to Predis if it can not find php-redis

Initial Title
Choose Redis connection method

Initial Tags


Initial Language
PHP