Aliyun Cloud Engine (ACE) is a linear scalable application hosting environment based on the flexible computing platform. Application template is that we learn from the industry's App store concept, simplifying the user to create the application of the steps to facilitate the application of the promotion. This article only describes the PHP application template porting, other languages please refer to the relevant documentation.
1. File, directory reading and writing
For security reasons, the ACE restricts local file reading and writing, user data is recommended in our OSS (open Storage services, high reliability and scalability of mass data storage), and file reading and writing requires the use of a unified interface provided by ACE. The ACE supports creating user data directories and also supporting creating directories on source code files.
PHP fread, Fwite has been closed by the ACE default, please use the following methods to implement.
Function Write ($fileName, $content, $sync =0) file writes$fileName file path (relative path) $content file content $sync Whether you need to sync to all Web side, to ensure multiple Web data synchronization, the default is set to 0 return True|false
Function Read ($fileName) reading file contents$fileName file path (relative path) returns the contents of the file |false
Function Delete ($fileName) Delete file$fileName file path (relative path) returns True|false
Member variable errno as error code
Member variable errmsg for debug with error message returned
The ace file read and write method is as follows:
Creating Cefile Objects
$ce = new Cefile ();
$ce->write ($fileName, $content, $sync =0);
Read File contents
2. File Cache Deployment
The main purpose of file caching is to save the frequently accessed data in local files, when there is a request to access the data directly, to avoid the request of the database again I/O operations, reduce the load pressure of the database.
Aces deploy two instances by default for each application, and the request is routed to an instance of it when there is a request for access. Aces are scalable and can increase or decrease the number of instances as requests increase and decrease. To improve performance, Aces also have file caching capabilities, such as caching configuration information. When the user modifies the configuration file, the function of the file cache should be called to synchronize the configuration information between multiple instances.
Therefore, if you use file caching in your application, you must use the file read-write interface provided by Ace and use the method to read and write files. Use a file cache deployment to set the Write method $sync synchronization parameter to 1.
3. Memcache Cache Deployment
Memcache Cache Management is a AACE distributed caching service for developers to cache the user's key-value form of small data in a shared way to speed up data response and reduce the pressure of back-end data processing.
The Memchae in the ACE environment is enabled by default and provides 64M free of charge to users. If the user needs to use the Memcache cache, be aware of the following considerations.
The Memcache APIs supported by the ACE are as follows:bool Memcache::init ()
Memcache APIs that are not supported by Aces are as follows:bool addserver* * (string $host [, int $port =
Application if you use the Memcache cache, you must use the Memcache cache interface provided by the ACE. The Memcache cache usage is as follows:
< PHP//Connection $mem = new Memcache (); Creates the Memcache object, and the internal access agent gets the address and ID $mem->init ();
4. File Upload
Files uploaded via the Web are based on OSS storage (OSS is the open storage service provided by Aliyun, and users can use OSS to build multimedia sharing sites such as pictures, videos, personal/enterprise data backup, etc. based on large-scale data).
Due to the limitations of the Ace platform, the uploaded files cannot be stored locally, only in Oss, the upload file interface provided by Ace must be used, and the corresponding URL will be generated after the file is uploaded. PHP's Move_uploaded_file method is no longer available, please use ACE to provide the method.
The file upload method is as follows:
Move_uploaded_file ($tmp _name, $filename)
To be replaced by:
$ce = new Acestorage ();
$result = $ce->upload ($tmp _name, $filename);
# $rs 1 = $ce->errmsg (); Output error message
# $rs 2 = $ce->errno ();
$result for the returned attachment file path, you can access it directly, such as:
5. Picture thumbnail, watermark and other special problems
Subject to local file read and write conditions, such as image thumbnails, watermarks and other functions are not supported, we will support in the subsequent version.
6. Data Backup Recovery problem
ACE provides online backup data functionality, and when you create an application, you can choose a backup point in time.
If you want to export data from an application, you need to work with the database client tool.