我试图按照此处的建议从缓存中删除模块。
在文档中,我们阅读:
require.cache
- 目的
需要时将模块缓存在此对象中。 通过从该对象中删除键值,下一个require将重新加载模块。
因此,我创建了一个1.js
包含一行的名为的文件:
module.exports = 1;
然后我需要通过node
外壳:
ionicabizau@laptop:~/Documents/test$ node
> require("./1")
1
> require.cache
{ '/home/ionicabizau/Documents/test/1.js':
{ id: '/home/ionicabizau/Documents/test/1.js',
exports: 1,
parent:
{ id: 'repl',
exports: [Object],
parent: undefined,
filename: '/home/ionicabizau/Documents/test/repl',
loaded: false,
children: [Object],
paths: [Object] },
filename: '/home/ionicabizau/Documents/test/1.js',
loaded: true,
children: [],
paths:
[ '/home/ionicabizau/Documents/test/node_modules',
'/home/ionicabizau/Documents/node_modules',
'/home/ionicabizau/node_modules',
'/home/node_modules',
'/node_modules' ] } }
# edited file to export 2 (module.exports = 2;)
> require.cache = {}
{}
> require.cache
{}
> require("./1") // supposed to return 2
1
那么,为什么不require("./1")
返回1
时,我的文件中包含module.exports = 2
和清除缓存?
进行调试时,我发现有一个Module._cache
对象在执行时未清除require.cache = {}
。
require.cache
只是公开的缓存对象引用,不会直接使用此属性,因此更改它不会执行任何操作。您需要遍历键,实际上是遍历delete
它们。
void clear_cache(string template [, string cache id [, string compile id [, int expire time]]]) This clears the cache for a specific template. If you have multiple caches for this template, you can cl
清除系统缓存 初衷 本身 Linux 有比较成熟的内存管理机制,但是不免也是会抽风的,有些程序在被 kill 掉之后系统内存依然没有大的变化,这时候就需要手动清除。 清除缓存 官网说明:http://www.kernel.org/doc/Documentation/sysctl/vm.txt 先查看目前系统内存使用情况:free -m 同步缓存数据到硬盘:sync 开始清理:echo 3 > /p
sp_clear_cache() 功能: 清除缓存 参数: 无 返回: 无 <?php sp_clear_cache();//无返回值 ?>
清除缓存文件clear 如果需要清除应用的缓存文件,可以使用下面的命令: php think clear 不带任何参数调用clear命令的话,会清除runtime目录(包括模板缓存、日志文件及其子目录)下面的所有的文件,但会保留目录。 如果需要清除某个指定目录下面的文件,可以使用: php think clear --path d:\www\tp5\runtime\log\ V5.1.10+版本开
我使用Drupal 7最新的开发版本。 我已经安装了清漆和过期模块并设置它们。它们工作得很好,但是我有一个关于从清漆中删除缓存的问题。 问题是如何只删除索引(主页)页面的清漆缓存,而不删除其他页面的缓存。我看了清漆日志,发现每次Drupal执行命令时,整个清漆缓存都被删除了 此命令由varnish模块或expire模块执行,它表示删除主页(索引)页的缓存。但正如我看到的,它正在删除varnish中
问题内容: 我需要在Symfony 2中清除我的学说的缓存。 命令行中必须有某种 清除缓存的方法 。 还是应该在哪里找到并删除属于缓存的文件? 问题答案: 将列出您的操作方法 对于symfony 3+: 和命令列表(用于从项目目录复制/粘贴):