💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
ThinkPHP5+测试Redis扩展 ~~~ <?php namespace app\index\controller; class RedisTest { public function redis() { $redis = new \Redis(); $redis->connect('127.0.0.1', 6379); // 如果没有密码则不需要这行 // $redis->auth('password'); // 把 'test'字符串存入 redis $redis->set('test_name', 'test'); // 把 'test_name' 的 值从 redis 读取出来 echo $redis->get('test_name'); echo ('<br/>'); // 往Redis List 列表存入数据 $redis->lpush("tutorial-list", "Redis"); $redis->lpush("tutorial-list", "Mongodb"); $redis->lpush("tutorial-list", "Mysql"); // 获取存入的data数据,并且输出 $arList = $redis->lrange("tutorial-list", 0, 5); echo "Stored string in redis:: "; echo ('<br/>'); print_r($arList); // 获取存入的键名并且输出 $arList = $redis->keys("*"); echo "Stored keys in redis:: "; echo ('<br/>'); print_r($arList); } } ~~~ 输出结果 ~~~ test Stored string in redis:: Array ( [0] => Mysql [1] => Mongodb [2] => Redis [3] => Mysql [4] => Mongodb [5] => Redis ) Stored keys in redis:: Array ( [0] => key [1] => mylist [2] => test_name [3] => tutorial-list ) ~~~