📅  最后修改于: 2021-01-07 09:16:09             🧑  作者: Mango
缓存是在Phalcon \ Cache目录下找到的类。它有助于以更快的速度访问常用数据。 Phalcon \ Cache用C编程语言编写,可减少开销。
缓存过程分为2部分:
1)前端:前端检查密钥是否已过期。在存储之前和从后端检索数据之后,还应对数据进行其他转换。
2)后端:后端部分负责通信,读取或写入前端所需的数据。
下面的代码通过实现前端和后端适配器,提供了2天缓存的基本缓存过程。
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,
[
'cacheDir' => '../app/cache/',
]
);
?>
Adapter | Description |
---|---|
Phalcon\Cache\Frontend\Output | Read input data from standard PHP output. |
Phalcon\Cache\Frontend\Data | It is used to cache any kind of PHP data (big arrays, objects, text, etc). Data is serialized before stored in the backend. |
Phalcon\Cache\Frontend\Base64 | It’s used to cache binary data. The data is serialized using base64_encode before be stored in the backend. |
Phalcon\Cache\Frontend\Json | Data is encoded in JSON before be stored in the backend. Decoded after be retrieved. This frontend is useful to share data with other languages or frameworks. |
Phalcon\Cache\Frontend\Igbinary | It is used to cache any kind of PHP data (big arrays, objects, text, etc). Data is serialized using Igbinary before be stored in the backend. |
Phalcon\Cache\Backend\Xcache | Stores data in XCache. |
Phalcon\Cache\Backend\None | It is used to cache any kind of PHP data without serializing them. |
Adapter | Description | Info | Required Extension |
---|---|---|---|
Phalcon\Cache\Backend\Apc | Stores data to the Alternative PHP Cache (APC). | APC | APC |
Phalcon\Cache\Backend\Apcu | Stores data to the APCu (APC without opcode caching) | APCu | APCu |
Phalcon\Cache\Backend\File | Stores data to local plain files | ||
Phalcon\Cache\Backend\Mongo | Stores data to Mongo Database. | MongoDB | MongoDB |
Phalcon\Cache\Backend\Redis | Stores data in Redis | Redis | Redis |
Phalcon\Cache\Backend\Xcache | Stores data in XCache. | XCache | XCache |
Phalcon\Cache\Backend\Memcache | Stores data to a memcached server. | Memcache | Memcache |