# 使用緩存提高性能(Improving Performance with Cache)
# 使用緩存提高性能(Improving Performance with Cache)
Phalcon提供的 <a class="calibre6 pcalibre1" href="">*Phalcon\\Cache*</a> 類可以更快地接入獲取使用頻繁或者已經被處理的數據。<a class="calibre6 pcalibre1" href="">*Phalcon\\Cache*</a> 是用C來編寫的,因此有著更高的性能并且能夠減少從后端獲取昂價資源所帶來的負載。
這個類使用了由前端和后端組件組成的內部結構。前端組件如輸入源或者接口,后端組件則為這個類提供了存儲的選項。
### 什么情況下使用緩存?(When to implement cache?)
盡管這個組件運行非常快速,但如果不加考慮就使用它會適得其反,特別在不需要或者不適宜使用緩存時。我們建議你在使用緩存前核對一下場景:
- 你正在進行復雜的運算,并且每次都返回相同的結果(或者變動很少)
- 你正在使用大量的插件生成大部分時間幾乎都是相同的頁面輸出
- 你正在頻繁地接入數據庫并且這些數據變動甚少
> *溫馨提示* 即使使用了這些緩存,你仍然應該定期檢測緩存的命中率。通過后臺提供的相關工具,這一點很容易做得到,特別是使用Memcache或者APC時。
### 緩存行為(Caching Behavior)
緩存流程可以分為兩部分:
- **前端**: 此部分負責檢測是否key已失效并且在保存數據和抓取數據后提供額外的轉換操作。
- **后端**: 此部分負責通訊,并根據前端進行數據的讀/寫。
### 緩存輸出片段(Caching Output Fragments)
輸出片段是指一小塊緩存和返回都一樣的HTML或者文本內容。輸出的內容應該是能自動被 ob\_\* 函數捕獲或者直接是PHP輸出,這樣才能緩存起來。以下實例演示了這樣的使用。它接收PHP生成的頁面輸出并保存在一個文件里面。緩存文件的內容每隔172800秒(2天)刷新一次。
使用這個緩存機制,無論何時調用這塊代碼,我們都可以通過避免重復執行輔助插件 Phalcon\\Tag::linkTo 從而獲得更高的性能。
```
<pre class="calibre14">```
<?php
use Phalcon\Tag;
use Phalcon\Cache\Backend\File as BackFile;
use Phalcon\Cache\Frontend\Output as FrontOutput;
// Create an Output frontend. Cache the files for 2 days
$frontCache = new FrontOutput(array(
"lifetime" => 172800
));
// Create the component that will cache from the "Output" to a "File" backend
// Set the cache file directory - it's important to keep the "/" at the end of
// the value for the folder
$cache = new BackFile($frontCache, array(
"cacheDir" => "../app/cache/"
));
// Get/Set the cache file to ../app/cache/my-cache.html
$content = $cache->start("my-cache.html");
// If $content is null then the content will be generated for the cache
if ($content === null) {
// Print date and time
echo date("r");
// Generate a link to the sign-up action
echo Tag::linkTo(
array(
"user/signup",
"Sign Up",
"class" => "signup-button"
)
);
// Store the output into the cache file
$cache->save();
} else {
// Echo the cached output
echo $content;
}
```
```
*溫馨提示* 在上面的實例中,我們的代碼維持不變,即輸出給用戶的內容和之前展示的內容是一樣的。我們的緩存組件以透明的方式捕獲了頁面輸出并保存在緩存文件(當緩存生成時)或者在早期的一次調用時將它發送回用戶預編譯,故而可以避免高昂的操作。
### 緩存任意數據(Caching Arbitrary Data)
僅僅是緩存數據,對于你的應用來說也是同等重要的。緩存通過重用常用的(非更新的)數據可以減少數據庫的加載,從而加速你的應用。
### 文件后端存儲器例子(File Backend Example)
其中一個緩存適配器是文件'File'。文件適配器的配置中只需要一個key:指明緩存文件存放的目錄位置。這個配置通過cacheDir選項控制,必須,且要以反斜杠結尾。
```
<pre class="calibre14">```
<?php
use Phalcon\Cache\Backend\File as BackFile;
use Phalcon\Cache\Frontend\Data as FrontData;
// Cache the files for 2 days using a Data frontend
$frontCache = new FrontData(array(
"lifetime" => 172800
));
// Create the component that will cache "Data" to a "File" backend
// Set the cache file directory - important to keep the "/" at the end of
// of the value for the folder
$cache = new BackFile($frontCache, array(
"cacheDir" => "../app/cache/"
));
// Try to get cached records
$cacheKey = 'robots_order_id.cache';
$robots = $cache->get($cacheKey);
if ($robots === null) {
// $robots is null because of cache expiration or data does not exist
// Make the database call and populate the variable
$robots = Robots::find(array("order" => "id"));
// Store it in the cache
$cache->save($cacheKey, $robots);
}
// Use $robots :)
foreach ($robots as $robot) {
echo $robot->name, "\n";
}
```
```
### Memcached 后端存儲器例子(Memcached Backend Example)
當我們改用Memcached作為后端存儲器時,上面的實例改動很輕微(特別就配置而言)。
```
<pre class="calibre14">```
<?php
use Phalcon\Cache\Frontend\Data as FrontData;
use Phalcon\Cache\Backend\Libmemcached as BackMemCached;
// Cache data for one hour
$frontCache = new FrontData(array(
"lifetime" => 3600
));
// Create the component that will cache "Data" to a "Memcached" backend
// Memcached connection settings
$cache = new BackMemCached($frontCache, array(
"servers" => array(
array(
"host" => "127.0.0.1",
"port" => "11211",
"weight" => "1"
)
)
));
// Try to get cached records
$cacheKey = 'robots_order_id.cache';
$robots = $cache->get($cacheKey);
if ($robots === null) {
// $robots is null because of cache expiration or data does not exist
// Make the database call and populate the variable
$robots = Robots::find(array("order" => "id"));
// Store it in the cache
$cache->save($cacheKey, $robots);
}
// Use $robots :)
foreach ($robots as $robot) {
echo $robot->name, "\n";
}
```
```
### 查詢緩存(Querying the cache)
添加到緩存的元素根據唯一的key進行識別區分。這使用文件緩存作為后端時,key就是實際的文件名。為了從緩存中獲得數據,我們僅僅需要通過唯一的key調用即可。如果key不存在,get方法將會返回null。
```
<pre class="calibre14">```
<?php
// Retrieve products by key "myProducts"
$products = $cache->get("myProducts");
```
```
如果你想知道在緩存中存放了哪些key,你可以調用queryKeys方法:
```
<pre class="calibre14">```
<?php
// Query all keys used in the cache
$keys = $cache->queryKeys();
foreach ($keys as $key) {
$data = $cache->get($key);
echo "Key=", $key, " Data=", $data;
}
// Query keys in the cache that begins with "my-prefix"
$keys = $cache->queryKeys("my-prefix");
```
```
### 刪除緩存數據(Deleting data from the cache)
有些時機你需要強制廢除一個緩存的實體(如對被緩存的數據進行了更新)。而僅僅需要做的只是知道對應緩存的數據存放于哪個key即可。
```
<pre class="calibre14">```
<?php
// Delete an item with a specific key
$cache->delete("someKey");
// Delete all items from the cache
$keys = $cache->queryKeys();
foreach ($keys as $key) {
$cache->delete($key);
}
```
```
### 檢查緩存是否存在(Checking cache existence)
也有可能需要根據一個給定的key來判斷緩存是否存在:
```
<pre class="calibre14">```
<?php
if ($cache->exists("someKey")) {
echo $cache->get("someKey");
} else {
echo "Cache does not exists!";
}
```
```
### 有效期(Lifetime)
“有效期”是指緩存可以多久時間(在以秒為單位)內有效。默認情況下,全部被創建的緩存都使用前端構建中設定的有效期。你可以在創建時指定一個有效期或者在從緩存中獲取數據時:
Setting the lifetime when retrieving:
```
<pre class="calibre14">```
<?php
$cacheKey = 'my.cache';
// Setting the cache when getting a result
$robots = $cache->get($cacheKey, 3600);
if ($robots === null) {
$robots = "some robots";
// Store it in the cache
$cache->save($cacheKey, $robots);
}
```
```
在保存時設置有效期:
```
<pre class="calibre14">```
<?php
$cacheKey = 'my.cache';
$robots = $cache->get($cacheKey);
if ($robots === null) {
$robots = "some robots";
// Setting the cache when saving data
$cache->save($cacheKey, $robots, 3600);
}
```
```
### 多級緩存(Multi-Level Cache)
緩存組件的特點,就是允許開發人員使用多級緩存。這個新特性非常有用,因為你可以在多個緩存媒介結合不同的有效期中保存相同的數據,并在有效期內從首個最快的緩存適配器開始讀取,直至到最慢的適配器。
```
<pre class="calibre14">```
<?php
use Phalcon\Cache\Multiple;
use Phalcon\Cache\Backend\Apc as ApcCache;
use Phalcon\Cache\Backend\File as FileCache;
use Phalcon\Cache\Frontend\Data as DataFrontend;
use Phalcon\Cache\Backend\Memcache as MemcacheCache;
$ultraFastFrontend = new DataFrontend(array(
"lifetime" => 3600
));
$fastFrontend = new DataFrontend(array(
"lifetime" => 86400
));
$slowFrontend = new DataFrontend(array(
"lifetime" => 604800
));
// Backends are registered from the fastest to the slower
$cache = new Multiple(array(
new ApcCache($ultraFastFrontend, array(
"prefix" => 'cache',
)),
new MemcacheCache($fastFrontend, array(
"prefix" => 'cache',
"host" => "localhost",
"port" => "11211"
)),
new FileCache($slowFrontend, array(
"prefix" => 'cache',
"cacheDir" => "../app/cache/"
))
));
// Save, saves in every backend
$cache->save('my-key', $data);
```
```
### 前端適配器(Frontend Adapters)
作為緩存的接口或者輸入源的前端適配器有:
### 自定義前端適配器(Implementing your own Frontend adapters)
為了創建你自己的前端適配器或者擴展已有的適配器,你必須實現 [*Phalcon\\Cache\\FrontendInterface*](#) 接口。
### 后端適配器(Backend Adapters)
用于存放緩存數據的后端適配器有:
### 自定義后端適配器(Implementing your own Backend adapters)
為了創建你自己的后端適配器或者擴展已有的后端適配器,你必須實現 [*Phalcon\\Cache\\BackendInterface*](#) 接口。
### 文件后端存儲器選項(File Backend Options)
此后端存儲器把緩存內容存放到本地服務器的文件。對應的選項有:
選項描述prefix自動追加到緩存key前面的前綴cacheDir放置緩存文件且可寫入的目錄### Memcached 后端存儲器選項(Memcached Backend Options)
此后端存儲器將緩存的內容存放在memcached服務器。對應的選項有:
選項描述prefix自動追加到緩存key前面的前綴hostmemcached 域名portmemcached 端口persistent創建一個長連接的memcached連接?### APC 后端存儲器選項(APC Backend Options)
此后端存儲器將緩存內容存放到opcode緩存(APC)。對應的選項有:
選項描述prefix自動追加到緩存key前面的前綴### Mongo 后端存儲器選項(Mongo Backend Options)
此后端存儲器將緩存內容存放到MongoDB服務器。對應的選項有:
選項描述prefix自動追加到緩存key前面的前綴serverMongoDB的連接串dbMongo數據庫名collectionMongo數據庫連接### XCache 后端存儲器選項(XCache Backend Options)
此后端存儲器將緩存內容存放到XCache ([XCache](http://xcache.lighttpd.net/))。對應的選項有:
選項描述prefix自動追加到緩存key前面的前綴在 [Phalcon Incubator](https://github.com/phalcon/incubator) 上還有更多針對這個組件可用的適配器
|
- [索引](# "總目錄")
- [下一頁](# "安全(Security)") |
- [上一頁](# "分頁(Pagination)") |
- API參考
- API列表
- Abstract class Phalcon\Acl
- Abstract class Phalcon\Acl\Adapter
- Class Phalcon\Acl\Adapter\Memory
- Interface Phalcon\Acl\AdapterInterface
- Class Phalcon\Acl\Exception
- Class Phalcon\Acl\Resource
- Interface Phalcon\Acl\ResourceInterface
- Class Phalcon\Acl\Role
- Interface Phalcon\Acl\RoleInterface
- Class Phalcon\Annotations\Annotation
- Abstract class Phalcon\Annotations\Adapter
- Interface Phalcon\Annotations\AdapterInterface
- Class Phalcon\Annotations\Collection
- Class Phalcon\Annotations\Exception
- Class Phalcon\Annotations\Reader
- Interface Phalcon\Annotations\ReaderInterface
- Class Phalcon\Annotations\Reflection
- Class Phalcon\Assets\Collection
- Class Phalcon\Assets\Exception
- Interface Phalcon\Assets\FilterInterface
- Class Phalcon\Assets\Filters\Cssmin
- Class Phalcon\Assets\Filters\Jsmin
- Class Phalcon\Assets\Filters\None
- Class Phalcon\Assets\Inline
- Class Phalcon\Assets\Inline\Css
- Class Phalcon\Assets\Inline\Js
- Class Phalcon\Assets\Manager
- Class Phalcon\Assets\Resource
- Class Phalcon\Assets\Resource\Css
- Class Phalcon\Assets\Resource\Js
- Abstract class Phalcon\Cache\Backend
- Class Phalcon\Cache\Backend\Apc
- Class Phalcon\Cache\Backend\File
- Class Phalcon\Cache\Backend\Libmemcached
- Class Phalcon\Cache\Backend\Memcache
- Class Phalcon\Cache\Backend\Memory
- Class Phalcon\Cache\Backend\Mongo
- Class Phalcon\Cache\Backend\Redis
- Class Phalcon\Cache\Backend\Xcache
- Interface Phalcon\Cache\BackendInterface
- Class Phalcon\Cache\Exception
- Class Phalcon\Cache\Frontend\Base64
- Class Phalcon\Cache\Frontend\Data
- Class Phalcon\Cache\Frontend\Igbinary
- Class Phalcon\Cache\Frontend\Json
- Class Phalcon\Cache\Frontend\None
- Class Phalcon\Cache\Frontend\Output
- Interface Phalcon\Cache\FrontendInterface
- Class Phalcon\Cache\Multiple
- Class Phalcon\Cli\Router\Route
- Class Phalcon\Config
- Class Phalcon\Config\Adapter\Ini
- Class Phalcon\Config\Adapter\Json
- Class Phalcon\Config\Adapter\Php
- Class Phalcon\Config\Adapter\Yaml
- Class Phalcon\Config\Exception
- Class Phalcon\Crypt
- Class Phalcon\Crypt\Exception
- Interface Phalcon\CryptInterface
- Abstract class Phalcon\Db
- Abstract class Phalcon\Db\Adapter
- Interface Phalcon\Db\AdapterInterface
- Class Phalcon\Db\Column
- Interface Phalcon\Db\ColumnInterface
- Abstract class Phalcon\Db\Dialect
- Interface Phalcon\Db\DialectInterface
- Class Phalcon\Db\Exception
- Class Phalcon\Db\Index
- Interface Phalcon\Db\IndexInterface
- Class Phalcon\Db\Profiler
- Class Phalcon\Db\RawValue
- Class Phalcon\Db\Reference
- Interface Phalcon\Db\ReferenceInterface
- Class Phalcon\Db\Result\Pdo
- Interface Phalcon\Db\ResultInterface
- Class Phalcon\Debug
- Class Phalcon\Debug\Dump
- Class Phalcon\Debug\Exception
- Interface Phalcon\DiInterface
- Abstract class Phalcon\Dispatcher
- Interface Phalcon\DispatcherInterface
- Class Phalcon\Escaper
- Class Phalcon\Escaper\Exception
- Interface Phalcon\EscaperInterface
- Class Phalcon\Events\Event
- Interface Phalcon\Events\EventsAwareInterface
- Class Phalcon\Events\Exception
- Class Phalcon\Events\Manager
- Interface Phalcon\Events\ManagerInterface
- Class Phalcon\Exception
- Class Phalcon\Filter
- Class Phalcon\Filter\Exception
- Interface Phalcon\Filter\UserFilterInterface
- Interface Phalcon\FilterInterface
- Abstract class Phalcon\Flash
- Class Phalcon\Flash\Direct
- Class Phalcon\Flash\Exception
- Class Phalcon\Flash\Session
- Interface Phalcon\FlashInterface
- Class Phalcon\Forms\Form
- Abstract class Phalcon\Forms\Element
- Class Phalcon\Forms\Exception
- Class Phalcon\Forms\Manager
- Class Phalcon\Http\Cookie
- Class Phalcon\Http\Cookie\Exception
- Class Phalcon\Http\Request
- Class Phalcon\Http\Request\Exception
- Class Phalcon\Http\Request\File
- Interface Phalcon\Http\Request\FileInterface
- Interface Phalcon\Http\RequestInterface
- Class Phalcon\Http\Response
- Class Phalcon\Http\Response\Cookies
- Interface Phalcon\Http\Response\CookiesInterface
- Class Phalcon\Http\Response\Exception
- Class Phalcon\Http\Response\Headers
- Interface Phalcon\Http\Response\HeadersInterface
- Interface Phalcon\Http\ResponseInterface
- Class Phalcon\Image
- Abstract class Phalcon\Image\Adapter
- Class Phalcon\Image\Adapter\Imagick
- Interface Phalcon\Image\AdapterInterface
- Class Phalcon\Image\Exception
- Class Phalcon\Kernel
- Class Phalcon\Loader
- Class Phalcon\Loader\Exception
- Abstract class Phalcon\Logger
- Abstract class Phalcon\Logger\Adapter
- Class Phalcon\Logger\Adapter\File
- Class Phalcon\Logger\Adapter\Firephp
- Class Phalcon\Logger\Adapter\Stream
- Class Phalcon\Logger\Adapter\Syslog
- Interface Phalcon\Logger\AdapterInterface
- Class Phalcon\Logger\Exception
- Abstract class Phalcon\Logger\Formatter
- Interface Phalcon\Logger\FormatterInterface
- Class Phalcon\Logger\Item
- Class Phalcon\Logger\Multiple
- Class Phalcon\Mvc\Application
- Class Phalcon\Mvc\Application\Exception
- Abstract class Phalcon\Mvc\Collection
- Abstract class Phalcon\Mvc\Collection\Behavior
- Class Phalcon\Mvc\Collection\Behavior\SoftDelete
- Class Phalcon\Mvc\Collection\Behavior\Timestampable
- Interface Phalcon\Mvc\Collection\BehaviorInterface
- Class Phalcon\Mvc\Collection\Document
- Class Phalcon\Mvc\Collection\Exception
- Class Phalcon\Mvc\Collection\Manager
- Interface Phalcon\Mvc\Collection\ManagerInterface
- Interface Phalcon\Mvc\CollectionInterface
- Abstract class Phalcon\Mvc\Controller
- Interface Phalcon\Mvc\ControllerInterface
- Class Phalcon\Mvc\Dispatcher
- Class Phalcon\Mvc\Dispatcher\Exception
- Interface Phalcon\Mvc\DispatcherInterface
- Interface Phalcon\Mvc\EntityInterface
- Class Phalcon\Mvc\Micro
- Class Phalcon\Mvc\Micro\Collection
- Interface Phalcon\Mvc\Micro\CollectionInterface
- Class Phalcon\Mvc\Micro\Exception
- Class Phalcon\Mvc\Micro\LazyLoader
- Interface Phalcon\Mvc\Micro\MiddlewareInterface
- Abstract class Phalcon\Mvc\Model
- Abstract class Phalcon\Mvc\Model\Behavior
- Class Phalcon\Mvc\Model\Criteria
- Interface Phalcon\Mvc\Model\CriteriaInterface
- Class Phalcon\Mvc\Model\Exception
- Class Phalcon\Mvc\Model\Manager
- Interface Phalcon\Mvc\Model\ManagerInterface
- Class Phalcon\Mvc\Model\Message
- Interface Phalcon\Mvc\Model\MessageInterface
- Abstract class Phalcon\Mvc\Model\MetaData
- Interface Phalcon\Mvc\Model\MetaDataInterface
- Class Phalcon\Mvc\Model\Query
- Interface Phalcon\Mvc\Model\QueryInterface
- Class Phalcon\Mvc\Model\Relation
- Interface Phalcon\Mvc\Model\RelationInterface
- Interface Phalcon\Mvc\Model\ResultInterface
- Abstract class Phalcon\Mvc\Model\Resultset
- Abstract class Phalcon\Mvc\Model\Validator
- Interface Phalcon\Mvc\Model\ResultsetInterface
- Class Phalcon\Mvc\Model\Row
- Class Phalcon\Mvc\Model\Transaction
- Interface Phalcon\Mvc\Model\TransactionInterface
- Class Phalcon\Mvc\Model\ValidationFailed
- Interface Phalcon\Mvc\ModelInterface
- Interface Phalcon\Mvc\ModuleDefinitionInterface
- Class Phalcon\Mvc\Router
- Class Phalcon\Mvc\Router\Annotations
- Class Phalcon\Mvc\Router\Exception
- Class Phalcon\Mvc\Router\Group
- Interface Phalcon\Mvc\Router\GroupInterface
- Class Phalcon\Mvc\Router\Route
- Interface Phalcon\Mvc\Router\RouteInterface
- Interface Phalcon\Mvc\RouterInterface
- Class Phalcon\Mvc\Url
- Class Phalcon\Mvc\Url\Exception
- Interface Phalcon\Mvc\UrlInterface
- Class Phalcon\Mvc\User\Component
- Class Phalcon\Mvc\User\Module
- Class Phalcon\Mvc\User\Plugin
- Class Phalcon\Mvc\View
- Abstract class Phalcon\Mvc\View\Engine
- Interface Phalcon\Mvc\View\EngineInterface
- Class Phalcon\Mvc\View\Exception
- Class Phalcon\Mvc\View\Simple
- Interface Phalcon\Mvc\ViewBaseInterface
- Interface Phalcon\Mvc\ViewInterface
- Abstract class Phalcon\Paginator\Adapter
- Class Phalcon\Paginator\Adapter\Model
- Class Phalcon\Paginator\Adapter\NativeArray
- Class Phalcon\Paginator\Adapter\QueryBuilder
- Interface Phalcon\Paginator\AdapterInterface
- Class Phalcon\Paginator\Exception
- Class Phalcon\Queue\Beanstalk
- Class Phalcon\Queue\Beanstalk\Job
- Final class Phalcon\Registry
- Class Phalcon\Security
- Class Phalcon\Security\Exception
- Abstract class Phalcon\Session
- Abstract class Phalcon\Session\Adapter
- Interface Phalcon\Session\AdapterInterface
- Class Phalcon\Session\Bag
- Interface Phalcon\Session\BagInterface
- Class Phalcon\Session\Exception
- Class Phalcon\Tag
- Class Phalcon\Tag\Exception
- Abstract class Phalcon\Tag\Select
- Abstract class Phalcon\Text
- Abstract class Phalcon\Translate
- Abstract class Phalcon\Translate\Adapter
- Class Phalcon\Translate\Adapter\Csv
- Class Phalcon\Translate\Adapter\Gettext
- Class Phalcon\Translate\Adapter\NativeArray
- Interface Phalcon\Translate\AdapterInterface
- Class Phalcon\Translate\Exception
- Class Phalcon\Validation
- Class Phalcon\Validation\Exception
- Class Phalcon\Validation\Message
- Class Phalcon\Validation\Message\Group
- Interface Phalcon\Validation\MessageInterface
- Abstract class Phalcon\Validation\Validator
- Class Phalcon\Validation\Validator\Alnum
- Class Phalcon\Validation\Validator\Alpha
- Class Phalcon\Validation\Validator\Between
- Class Phalcon\Validation\Validator\Confirmation
- Class Phalcon\Validation\Validator\Digit
- Class Phalcon\Validation\Validator\Email
- Class Phalcon\Validation\Validator\ExclusionIn
- Class Phalcon\Validation\Validator\File
- Class Phalcon\Validation\Validator\Identical
- Class Phalcon\Validation\Validator\InclusionIn
- Class Phalcon\Validation\Validator\Numericality
- Class Phalcon\Validation\Validator\PresenceOf
- Class Phalcon\Validation\Validator\Regex
- Class Phalcon\Validation\Validator\StringLength
- Class Phalcon\Validation\Validator\Uniqueness
- Class Phalcon\Validation\Validator\Url
- Interface Phalcon\Validation\ValidatorInterface
- Class Phalcon\Version
- 參考手冊
- 安裝(Installation)
- 教程 1:讓我們通過例子來學習(Tutorial 1: Let’s learn by example)
- 教程 2:Introducing INVO(Tutorial 2: Introducing INVO)
- 教程 3: Securing INVO
- 教程 4: Using CRUDs
- 教程 5: Customizing INVO
- 教程 6: Vkuró
- 教程 7:創建簡單的 REST API(Tutorial 7: Creating a Simple REST API)
- 示例列表(List of examples)
- 依賴注入與服務定位器(Dependency Injection/Service Location)
- MVC 架構(The MVC Architecture)
- 使用控制器(Using Controllers)
- 使用模型(Working with Models)
- 模型元數據(Models Meta-Data)
- 事務管理(Model Transactions)
- Phalcon 查詢語言(Phalcon Query Language (PHQL))
- 緩存對象關系映射(Caching in the ORM)
- 對象文檔映射 ODM (Object-Document Mapper)
- 使用視圖(Using Views)
- 視圖助手(View Helpers)
- 資源文件管理(Assets Management)
- Volt 模版引擎(Volt: Template Engine)
- MVC 應用(MVC Applications)
- 路由(Routing)
- 調度控制器(Dispatching Controllers)
- 微應用(Micro Applications)
- 使用命名空間(Working with Namespaces)
- 事件管理器(Events Manager)
- Request Environment
- 返回響應(Returning Responses)
- Cookie 管理(Cookies Management)
- 生成 URL 和 路徑(Generating URLs and Paths)
- 閃存消息(Flashing Messages)
- 使用 Session 存儲數據(Storing data in Session)
- 過濾與清理(Filtering and Sanitizing)
- 上下文編碼(Contextual Escaping)
- 驗證(Validation)
- 表單(Forms)
- 讀取配置(Reading Configurations)
- 分頁(Pagination)
- 使用緩存提高性能(Improving Performance with Cache)
- 安全(Security)
- Encryption/Decryption
- 訪問控制列表 ACL(Access Control Lists ACL)
- 多語言支持(Multi-lingual Support)
- Universal Class Loader
- 日志記錄(Logging)
- 注釋解析器(Annotations Parser)
- 命令行應用(Command Line Applications)
- 隊列(Queueing)
- 數據庫抽象層(Database Abstraction Layer)
- 國際化(Internationalization)
- 數據庫遷移(Database Migrations)
- 調試應用程序(Debugging Applications)
- Phalcon 開發工具(Phalcon Developer Tools)
- 提高性能:下一步該做什么?(Increasing Performance: What’s next?)
- 單元測試(Unit testing)
- 授權(License)