rollerworks / uri-encoder-doctrine-cache
此包已被废弃且不再维护。未建议替代包。
为Rollerworks URIEncoder组件提供Doctrine缓存适配器
v1.0.0
2015-09-19 14:24 UTC
Requires
- php: >=5.4
- doctrine/cache: ^1.4.2
- rollerworks/uri-encoder: ^1.0.0
This package is not auto-updated.
Last update: 2022-02-01 12:51:28 UTC
README
此包为Rollerworks URIEncoder组件提供Doctrine缓存适配器。
安装
要安装此包,将rollerworks/uri-encoder-doctrine-cache
添加到您的composer.json文件中
$ php composer.phar require rollerworks/uri-encoder-doctrine-cache
然后,您可以通过在您的composer.json
文件所在的目录中运行Composer的update
命令来安装新的依赖项
$ php composer update rollerworks/uri-encoder-doctrine-cache
现在,Composer将自动下载所有必需的文件,并为您安装它们。
使用方法
require 'vendor/autoload.php'; use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\ChainCache; use Rollerworks\Component\UriEncoder\Encoder as UriEncoder; use Rollerworks\Component\UriEncoder\Cache\DoctrineCache; // The Doctrine cache library. $doctrineCache = new ChainCache( [ // Include the ArrayCache as the ChainCache will populate all the previous cache layers. // So if the `FilesystemCache` has a match it will populate the faster ArrayCache. new ArrayCache(), // Add an simple cache for fast access, eg. the rollerworks session-cache library. // https://github.com/rollerworks/Cache ] ); // Rollerworks\Component\UriEncoder\CacheAdapterInterface $cacheDriver = new DoctrineCache($doctrineCache); $stringEncode = 'This string is not safe, for direct usage & must encoded'; $base64Encoder = new UriEncoder\Base64UriEncoder(); $cacheEncoder = new UriEncoder\CacheEncoderDecorator($cacheDriver, $base64Encoder); $safeValue = $cacheEncoder->encodeUri($stringEncode); // $safeString now contains a base64 encoded string // and the result is cached using the cacheDriver. $originalValue = $cacheEncoder->decodeUri($safeValue);