PHP code example of lizus / php-redis

1. Go to this page and download the library: Download lizus/php-redis library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lizus / php-redis example snippets


if (!defined('PHPREDIS_HOST')) define('PHPREDIS_HOST', '127.0.0.1');
if (!defined('PHPREDIS_PORT')) define('PHPREDIS_PORT', '6379');

if (!defined('PHPREDIS_AUTH')) define('PHPREDIS_AUTH', 'your auth');

if (!defined('PHPREDIS_DATABASE')) define('PHPREDIS_DATABASE', 'your database');

use \Lizus\PHPRedis\PHPRedis;

class SampleRedis extends PHPRedis 
{
    protected $database=1; //Not necessary 自定义数据库
    protected $host='127.0.0.1'; //Not necessary 自定义host
    protected $port='6379'; //Not necessary 自定义port
    protected $auth='***'; //Not necessary 自定义auth
}


$a=new SampleRedis('sampleName');

$a->set('sample data');

var_dump($a->get());