Use Redis on PHP to increase the number of key values, as shown in the following example:
$set [' money '] = $this->redis->hincrbyfloat ($key, $hour. _money ', $data [' money ']);
$set [' ip '] = $this->redis->hincrby ($key, $hour. _ip ', $data [' IP ']);
$set [' uv '] = $this->redis->hincrby ($key, $hour. _uv ', $data [' UV ']);
$set [' PV '] = $this->redis->hincrby ($key, $hour. _PV ', $data [' PV ']);
$this->redis->hset ($key, $hour, Array ($data [' money '], $data [' IP '], $data [' UV '], $data [' PV ']));
If you may need to ask five times to write this, you can do this one at a time by using the Eval method, greatly improving your efficiency
$script = ' local money = Redis.call ("Hincrbyfloat", Keys[1], argv[1], argv[2]);
$script. = ' Local IP = Redis.call ("Hincrby", Keys[1], argv[3], argv[4]);
$script. = ' Local UV = Redis.call ("Hincrby", Keys[1], argv[5], argv[6]);
$script. = ' Local PV = Redis.call ("Hincrby", Keys[1], argv[7], argv[8]);
$script. = ' Local val = money ... ', '. IP ... ",".. UV ... ",".. PV; ';
$script. = ' Redis.call ("Hset", Keys[1], argv[2], Val);
$script. = ' return val; ';
$result = $this->redis->evaluate ($script, [$key, $hour, $hour. _money ', $data [' money '], $hour. ' _ip ', $data [' IP '], $hour. ' _uv ', $data [' UV '], $hour. ' _PV ', $data [' PV ']], 2);
Var_dump ($result);
I'm not familiar with the Lua syntax for Redis, and this string concatenation is also very special with two dots "..."
Money ... ",". IP ... ",".. UV ... ",".. PV
splicing after
0.01,1,2,3
The above Redis uses the Eval multiple key value self increment operation example is small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.