宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

这篇文章主要介绍“php的hIncrBy和hIncrByFloat怎么用”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“php的hIncrBy和hIncrByFloat怎么用”文章能帮助大家解决问题。

<?php
namespace app\index\controller;
use Redis;
class Index
{
    public function index)
    {
        $redis = new Redis);
        $redis->connect'127.0.0.1', 6379);
        $redis->flushAll);

        /**
         * redis hash是一个string类型的field和value映射表,特别适用于存储对象
         */

        // hSet) 添加一个value到hash中
        $redis->hSet'h','k1','1');
        $redis->hSet'h','k2','2');
        $redis->hSet'h','k3','v3');
        // 为key对应的value增加参数value
        $redis->hIncrBy'h','k1',99);
        // 为key对应的value增加参数value 浮点型
        $redis->hIncrByFloat'h','k2',98.00);
        
        $res = $redis->hGetAll'h');
        var_dump$res);
        /**
         *
         */



    }




}