Cakephp:tips on SSL, MySQL load balance, mas_php tutorial

Source: Internet
Author: User
1. CakePHP Master/slave
*) Add default (slave as for query) setting in database.php, and master for saving
*) Define a new replicate behavior

Class Replicationbehavior extends Modelbehavior {

Public Function BeforeSave ($Model) {
$Model->usedbconfig = master;
}

Public Function Aftersave ($Model) {
$Model->usedbconfig = default;
}

Public Function Setserver ($Model, $server) {
$Model->__backupconfig = $Model->usedbconfig;
$Model->usedbconfig = $server;
}

Public Function Afterfind ($Model) {
if (!empty ($Model->__backupconfig)) {
$this->usedbconfig = $Model->__backupconfig;
}
$Model->__backupconfig = null;
}

Public Function Save ($data = null, $validate = true, $whitelist = Array ()) {
$this->replication->beforesave ($this);
Return Parent::save ($data, $validate, $whitelist);
}

}

?>
*) Set $actAs to has replicate behavior in your base app model
$actAs = Array (Replicate);

*) Call the Setserver method in your controller to determine which database you want to use for instant query after save
if ($this->deal->saveall ($this->data, Array (Validate=>first))) {
$this->deal->setserver (master);
$deal = $this->deal->find (First,array (
conditions = Array (slug = $this->data[deal][slug]),
Fields = Array (ID)
));

2 xhprof (a PHP benchmark tool developed by Facebook)
http://techportal.ibuildings.com/2009/12/01/profiling-with-xhprof/

3. MySQL load-balancing
Mysql-load-balancing-proxy-trafficscript ">http://www.zeus.com/community/articles/ Building-mysql-load-balancing-proxy-trafficscript

4. SSL
Consolidate secure operations to single domain:https://lang.secure.jigocity.com
Keep track of Referer links in HTTP header
Redirect back to the original Referer when done

http://www.bkjia.com/PHPjc/478813.html www.bkjia.com true http://www.bkjia.com/PHPjc/478813.html techarticle 1. CakePHP master/slave *) Add default (Slave as for query) setting in database.php, and Master for saving *) define a New replicate behavior? PHP class Replicationbehavior extends ...

  • 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.