PHP code example of colaphp / redis

1. Go to this page and download the library: Download colaphp/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/ */

    

colaphp / redis example snippets



$servers = [
	'default' => [
		'host' => '192.168.0.1',
		'port' => 6379,
		'database' => 1,
	],
	'options' => [
        'cluster' => 'redis'
    ],
	'cluster' => false,//分布式配置
];

//实例
$RedisDb = new \Colaphp\Redis\RedisDb($servers);
$RedisStore =  new \Colaphp\Redis\RedisStore($RedisDb, 'prefix', 'default');
//也可直接用助手函数
$RedisStore = getRedis('prefix', 'default', $servers);

//调用
$RedisStore->get
$RedisStore->put
...