Predis set method is slow and slow, what is the reason?

Source: Internet
Author: User
Here is my code:


  Redis) {$cfg = [' scheme ' = + env (' Redis_scheme ', ' TCP '), ' host ' = env (' RE            Dis_host ', ' 127.0.0.1 '), ' port ' = env (' Redis_port ', 6379)];        $this->redis = new \predis\client ($CFG);    }}/** * Close the session * @since 5.4.0 */Public Function Close () {return true;    }/** * Destroy a session * @return Boolean * @since 5.4.0 */Public Function Destroy ($session _id)        {$this->connect ();        $this->redis->del ($session _id);    return true;    }/** * Cleanup old Sessions * @return Boolean * @since 5.4.0 */Public Function GC ($MAXLIFETIME)    {return true;        }/** * Initialize session * @since 5.4.0 */Public Function open ($save _path, $sessionName) {    return true; }/** * Read session data * @return String * @since 5.4.0 */Public function Read ($session _id) {$this->connect ();            if ($this->redis->exists ($session _id)) {$value = $this->redis->get ($session _id); Return $value?        ($value): ';            } else {$expire = Configure (' Ymf.Account.expire ');            $this->redis->setex ($session _id, $expire, ");        Return ';    } return '; }/** * Write session Data * @return Boolean * @since 5.4.0 */Public Function Write ($session _id, $s        Essiondata) {$this->connect (); File_put_contents (__dir__. '/.. /..        /write.log ', "write {$sessionData}\r\n", file_append);        if ($this->redis->set ("Flf", "HFL")) {return true;        } else {return false; }    }}

Troubleshooting will only, find this $this->redis->set method particularly slow, what reason ....

Reply content:

Here is my code:


  Redis) {$cfg = [' scheme ' = + env (' Redis_scheme ', ' TCP '), ' host ' = env (' RE            Dis_host ', ' 127.0.0.1 '), ' port ' = env (' Redis_port ', 6379)];        $this->redis = new \predis\client ($CFG);    }}/** * Close the session * @since 5.4.0 */Public Function Close () {return true;    }/** * Destroy a session * @return Boolean * @since 5.4.0 */Public Function Destroy ($session _id)        {$this->connect ();        $this->redis->del ($session _id);    return true;    }/** * Cleanup old Sessions * @return Boolean * @since 5.4.0 */Public Function GC ($MAXLIFETIME)    {return true;        }/** * Initialize session * @since 5.4.0 */Public Function open ($save _path, $sessionName) {    return true; }/** * Read session data * @return String * @since 5.4.0 */Public function Read ($session _id) {$this->connect ();            if ($this->redis->exists ($session _id)) {$value = $this->redis->get ($session _id); Return $value?        ($value): ';            } else {$expire = Configure (' Ymf.Account.expire ');            $this->redis->setex ($session _id, $expire, ");        Return ';    } return '; }/** * Write session Data * @return Boolean * @since 5.4.0 */Public Function Write ($session _id, $s        Essiondata) {$this->connect (); File_put_contents (__dir__. '/.. /..        /write.log ', "write {$sessionData}\r\n", file_append);        if ($this->redis->set ("Flf", "HFL")) {return true;        } else {return false; }    }}

Troubleshooting will only, find this $this->redis->set method particularly slow, what reason ....

  • Related Article

    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.