还存储Symfony 2缓存吗? [英] Storing Symfony 2 cache elsewere?

查看:43
本文介绍了还存储Symfony 2缓存吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以将symfony 2缓存(应用程序/缓存)存储在文件系统以外的其他位置? Memcache,S3还是其他?有内置选项吗?

Is there a way to store symfony 2 cache (app/cache) somewhere else other than the filesystem? Memcache, S3, or something? Any built-in option?

推荐答案

您只能通过重载AppKernel中的getCacheDir()方法将其移至项目目录之外。

You can only move it outside of the project directory by overloading getCacheDir() method in the AppKernel class.

将其移至Memcache的意义何在?该目录的内容大多数时候是已编译的类和模板。这些文件无论如何都会存入内存(APC会这样做)。

What's the point of moving it to Memcache? Contents of this directory is most of the time "compiled" classes and templates. Those files are put into memory anyway (APC does that).

编辑:在开发中,避免I / O较为困难,但是您可以通过覆盖AppKernel的 getCacheDir() getLogDir()方法轻松将Symfony的缓存目录移至内存,以将它们指向 / dev / shm

Edit: On development, it's harder to avoid I/O, but you can easily move Symfony's cache dir to memory by overriding AppKernel's getCacheDir() and getLogDir() methods to point them to /dev/shm:

class AppKernel extends Kernel
{
    // ...

    public function getCacheDir()
    {
        if (in_array($this->environment, array('dev', 'test'))) {
            return '/dev/shm/appname/cache/' .  $this->environment;
        }

        return parent::getCacheDir();
    }

    public function getLogDir()
    {
        if (in_array($this->environment, array('dev', 'test'))) {
            return '/dev/shm/appname/logs';
        }

        return parent::getLogDir();
    }
}

来源: http://www.whitewashing.de/2013/08/19/speedup_symfony2_on_vagrant_boxes.html

这篇关于还存储Symfony 2缓存吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆