データを Symfony のファイル キャッシュに保存したいと考えています。read() および write() メソッドを使用してアプリ/キャッシュ キャッシュと対話する良い方法はありますか?
編集
優れたwinzou CacheBundleはまさに私が必要としていたものでした。
データを Symfony のファイル キャッシュに保存したいと考えています。read() および write() メソッドを使用してアプリ/キャッシュ キャッシュと対話する良い方法はありますか?
編集
優れたwinzou CacheBundleはまさに私が必要としていたものでした。
コントローラーから実行できます:
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOException;
//Define your file path based on the cache one
$filename = $this->container->getParameter('kernel.cache_dir') . '/yourapp/filename.txt';
//Create your own folder in the cache directory
$fs = new Filesystem();
try {
$fs->mkdir(dirname($filename));
} catch (IOException $e) {
echo "An error occured while creating your directory";
}
//Write your file
file_put_contents($filename, 'Text content');
//Read the content of your file
echo file_get_contents($filename);
Note that DoctrineCacheBundle is now recommended. Don't be misled by the Doctrine branding - this is distinct and separate from the ORM and DBAL etc.
何を達成しようとしているのかはよくわかりませんが、構成コンポーネントのドキュメント、特に ConfigCache クラスを見てください。
http://symfony.com/doc/current/components/config/index.html
http://symfony.com/doc/current/components/config/caching.html