1. use $ uses and loadModel in CakePHP1.3.x to avoid using $ uses as much as possible, because this will load all the models used, occupying memory and consuming unnecessary time. Instead, use loadModel to load a model. Set the recursive Syn attribute when no data is associated.
1. use of $ uses and loadModel
In CakePHP1.3.x, try not to use $ uses, because this will load all the models used, occupying memory and consuming unnecessary time.
Instead, use loadModel to load a model. If you do not need to associate data, set the recursive attribute to-1.
In addition, the default data model of the controller does not need to be loaded. if users_controller does not need to call loadModel (User), the User model and its associated model are automatically loaded,
In the controller, you only need to use it directly:
$ This-> User ...;
$ This-> User-> Role...
With lazy loading technology, version 1.3 has a lazy_model that replaces the base class of your app_model with LazyModel,
The model will be loaded only in actual calls.
2. use of eval and requestAction
Do not use eval and requestAction whenever possible. Eval will cause a new script to parse the process, and requestAction is equivalent to sending a new request.
Eval can be replaced with a syntax similar to {} or $, as shown in figure
Case 1
$ This-> {$ this-> modelClass}-> hasField ("country_id ");
-----------------------------------------------------------------
Case 2
$ Foo = city;
$ Foo = shanghai;
Replace requestAction with view/helper
3. Cache
Memcached is used for distributed data sharing, and Apc is used for local data whenever possible. Specify the Cache configured in core. php by using the parameter where Cache: write/read is used.