CakePHP 3.x 如何使用控制台清除视图缓存?

Kim*_*cks 8 bash caching cakephp cakephp-3.0

我的 CakePHP 3.x 应用程序托管在 bitbucket 中。

我有一个部署脚本,它将 git clone 到一个使用时间戳作为文件夹名称的文件夹。

之后脚本将创建/var/virtual/webapp/current指向这个带时间戳的文件夹的符号链接。

然而,出于某种原因,尽管有这个新部署的文件夹,视图文件仍然被缓存。该tmp文件夹也是空的。

如何使用控制台清除视图文件的缓存,以便将其添加到 bash 脚本中?

'Cache' => [
        'default' => [
            'className' => 'File',
            'path' => CACHE,
        ],

        /**
         * Configure the cache used for general framework caching. Path information,
         * object listings, and translation cache files are stored with this
         * configuration.
         */
        '_cake_core_' => [
            'className' => 'File',
            'prefix' => 'myapp_cake_core_',
            'path' => CACHE . 'persistent/',
            'serialize' => true,
            'duration' => '+2 minutes',
        ],

        /**
         * Configure the cache for model and datasource caches. This cache
         * configuration is used to store schema descriptions, and table listings
         * in connections.
         */
        '_cake_model_' => [
            'className' => 'File',
            'prefix' => 'myapp_cake_model_',
            'path' => CACHE . 'models/',
            'serialize' => true,
            'duration' => '+2 minutes',
        ],
    ],
Run Code Online (Sandbox Code Playgroud)

Fur*_*ury 11

尝试这个

// Clear one cache config
bin/cake cache clear <configname>

// Clear all cache configs
bin/cake cache clear_all
Run Code Online (Sandbox Code Playgroud)


sty*_*yks 1

那么您想从控制台清除缓存吗?

清除 Cakephp 中的缓存

以下内容不适合您吗?

// Will only clear expired keys.
Cache::clear(true);

// Will clear all keys.
Cache::clear(false);
Run Code Online (Sandbox Code Playgroud)

您可以创建一个 shell 脚本并将其放在那里。

外壳和控制台

或者只需删除您使用 rm 指定用于缓存的文件夹中的所有文件...

rm -f /path/to/my/cached/files/*
Run Code Online (Sandbox Code Playgroud)

聚苯乙烯

  • 这不包括通过 php opcache 缓存的任何内容。启用了吗?这也可能是缓存视图文件的原因
  • 您的脚本也有可能实际上并未将符号链接更新到当前目录?