您好,欢迎来到外链网!
当前位置:外链网 » 站长资讯 » 专业问答 » 文章详细 订阅RssFeed

【thinkphp5操作redis系列教程】列表类型之lIndex,lGet

来源:互联网 浏览:71次 时间:2023-04-08
<?phpnamespace app\index\controller;use Redis;class Index{ public function index() { $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $redis->flushAll(); $redis->rPush('k1','a'); $redis->rPush('k1','b'); $redis->rPush('k1','c'); // lIndex() lGet() 根据索引获取key的值,从0开始 echo $redis->lIndex('k1',0);//a echo $redis->lIndex('k1',1);//b echo $redis->lIndex('k1',2);//c echo $redis->lGet('k1',2); //c }} 92449902