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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29893003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 12:52:55  来源:igfitidea点击:

CakePHP 3.x How to clear cache for views using console?

bashcakephpcachingcakephp-3.0

提问by Kim Stacks

My CakePHP 3.x app is hosted in bitbucket.

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

I have a deploy script that will git clone to a folder that uses timestamp as folder name.

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

After which the script will then create symlink /var/virtual/webapp/currentto this timestamped folder.

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

However, for some reason, the view files are still cached despite this newly deployed folder. Also the tmpfolder is empty.

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

How do I clear cache for view files using the console, so I can add it into the bash script?

如何使用控制台清除视图文件的缓存,以便将其添加到 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',
        ],
    ],

回答by Fury

Try this

尝试这个

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

// Clear all cache configs
bin/cake cache clear_all

回答by styks

So you want to clear the cache from the console?

所以你想从控制台清除缓存?

Clearing Cache in Cakephp

在 Cakephp 中清除缓存

Does the below not work for you?

以下不适合您吗?

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

// Will clear all keys.
Cache::clear(false);

You could create a shell script and could put it there.

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

Shells and Console

外壳和控制台

Or just delete all the files in the folder you specified for cache with rm...

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

rm -f /path/to/my/cached/files/*

P.S.

聚苯乙烯

  • This does not cover anything cached via php opcache. Is that enabled? That could also be what is caching the view files
  • There is also the potential that your script isn't actually updating the symlink to the current directory?
  • 这不包括通过 php opcache 缓存的任何内容。启用了吗?这也可能是缓存视图文件的原因
  • 也有可能您的脚本实际上并未将符号链接更新到当前目录?

回答by user9652823

You can use next command to clear allcache via console: bin/cake console Cake\Cache\Cache::clear(false)

您可以使用 next 命令通过控制台清除所有缓存: bin/cake console Cake\Cache\Cache::clear(false)

CakePHP: Clearing Cached Data

CakePHP:清除缓存数据