Models forcing cache (model forced caching) in Phalcon pits

Source: Internet
Author: User

Follow Phalcon Official document go to the Model force cache, an old error occurred: Cache didn ' t return a valid resultset.

The exact meaning is that the cache does not return a valid result set.

Modelscache as follows:

/**
* @return Redis
*/
Public Function Getmodelcache ()
{
$frontend = new Json ([
"Lifetime" = $this->config->model->lifetime,
]);

return new Redis ($frontend, [
"Host" = $this->config->model->host,
"Port" = $this->config->model->port,
"Persistent" = False,
"Statskey" = $this->keyslistname,
"Index" = $this->config->model->database,
]);
}
Look at the source code on GitHub:

Let cache = this->_dependencyinjector->getshared (cacheservice);
If typeof Cache! = "Object" {
throw new Exception ("Cache service must is an object");
}

Let result = Cache->get (key, Lifetime);
If result!== null {

If typeof result! = "Object" {
throw new Exception ("Cache didn ' t return a valid resultset");
}

Result->setisfresh (FALSE);

......

This exception is thrown when the result returned by the cache is not an object, and it is worth noting that the data returned after processing using cryptographic classes such as Json,base64 has lost the original class information. So there will be an error. Therefore, it is possible to use the data class that comes with it to encrypt and decrypt it. The encryption and decryption used by the data class are PHP serialize and unserialize. The original data information is not lost.

Models forcing cache (model forced caching) in Phalcon pits

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.