[php] 2025-01-16 圈点548
摘要:thinkphp5操作redis步骤简介
thinkphp5操作redis步骤简介:
1,在php.ini中添加php_redis.dll /php_redis.so的扩展。注意重新启动php。
2,在thinkphp5的redis的类中配置参数。
路径为:thinkphp/library/think/cache/driver/Redis.php
注意:参数在此文件头部,按实际情况填写参数。
3,在项目中引用redis类。
如:use think\cache\driver\Redis;
4,使用方法。
$redis=new Redis();
$redis->set('x','x');
$redis->get('x');
5,使用list数据的方法。
$redis->handler()->lpush($rdsname,$num);
$redis->handler()->rpush($rdsname,$num);
$redis->handler()->lrange($rdsname,0,-1);
$redis->handler()->lindex($rdsname,0);