PHP Redis Hincrby incrementing problem

Source: Internet
Author: User
Tags php redis

The first time the request is made, Hgetall count_comment returns 58 , and then hincrBy +1 , the hGetAll expected return is count_comment 59 turned 1 . The expected incremental effect is not achieved.

Executing the same request again, Hgetall returns count_comment 1 , and then returns it again hincrBy +1 hGetAll count_comment 2 . This request hincrBy +1 is an expected increment of the implementation.

It is not clear what is the cause of the situation, for a long time did not find the reason.
Here is redis used phpredis to connect
count_commentare all string types.

Reply content:

The first time the request is made, Hgetall count_comment returns 58 , and then hincrBy +1 , the hGetAll expected return is count_comment 59 turned 1 . The expected incremental effect is not achieved.

Executing the same request again, Hgetall returns count_comment 1 , and then returns it again hincrBy +1 hGetAll count_comment 2 . This request hincrBy +1 is an expected increment of the implementation.

It is not clear what is the cause of the situation, for a long time did not find the reason.
Here is redis used phpredis to connect
count_commentare all string types.

I found a problem.

This is expected, you can ' t run INCR, Incrby, or Hincrby on serialized data.

When you initialize Redis, you are using the SERIALIZER format store

$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.