Home Backend Development PHP Tutorial CakePHP: Performance Considerations_PHP Tutorial

CakePHP: Performance Considerations_PHP Tutorial

Jul 13, 2016 pm 05:43 PM
cakephp use and exist performance of consider

1. Use of $uses and loadModel

Try not to use $uses in CakePHP 1.3.x version, because this will load all the used models, occupy memory and consume unnecessary time.

On the contrary, where you need to use the model, use loadModel to load it. If no associated data is required, set its recursive property to -1.

In addition, the default data model of the controller does not need to be loaded. If users_controller does not call loadModel(User), the User model and its associated models will be loaded automatically,

Just use it directly in the controller:

$this->User... ;

$this->User->Role...

Use lazy loading technology, version 1.3 has a lazy_model, replace the base class of your app_model with LazyModel,

will cause the model to be loaded only where it is actually called.

2. Use of eval and requestAction

Try not to use eval and requestAction. eval will cause a new script parsing process, and requestAction is equivalent to issuing a new request.

eval can be replaced with {} or $$ similar syntax, such as

case 1 

$this->{$this->modelClass}->hasField("country_id");

-------------------------------------------------- ------------------

case 2

$foo = city;

$$foo = shanghai;

requestAction is replaced with view/helper

3. Cache

Use memcached where distributed data sharing is required, and try to use Apc for local data. Where Cache::write/read is used, specify which Cache configured in core.php is used through parameters.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478816.htmlTechArticle1. The use of $uses and loadModel. Try not to use $uses in CakePHP1.3.x version, because this All used models will be loaded, occupying memory and unnecessary time. On the contrary, when you need to use...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

See all articles