PHP code example of xiucaiwu / tp5redis

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

    

xiucaiwu / tp5redis example snippets


config/redis.php
return [
	'host' => '127.0.0.1', // redis主机
	'port' => '', // redis端口
	'password' => '', // 密码
	'select' => 0, // 操作库
	'expire' => 0, // 有效期(秒)
	'timeout' => 0, // 超时时间(秒)
	'persistent' => true, // 是否长连接
	'prefix' => '', //前缀
];


	namespace app\index\controller;
	use tp5redis\Redis;

	class index
	{
		public function test()
		{
			  Redis::set('abc',111);
			  $res = Redis::get('abc');
			  var_dump($res);  //输出111代表成功
		}
	}