cachewrtbuild icon indicating copy to clipboard operation
cachewrtbuild copied to clipboard

【bug】缓存总是命中

Open bob-zebedy opened this issue 4 years ago • 3 comments

https://github.com/klever1988/cachewrtbuild/blob/4e49fc2aa43955b2933541b0372f7416f7dac23d/fetch.js#L18-L19 由于 restoreKeys = ['cache-openwrt']restoreKeys = ['cache-openwrt', 'cache-openwrt-<commithash>'] 下面再查缓存的时候 https://github.com/klever1988/cachewrtbuild/blob/4e49fc2aa43955b2933541b0372f7416f7dac23d/fetch.js#L40 keyString 包含时间戳,肯定不会命中,所以会用 restoreKeys 依次去查 但是因为缓存的 key = cache-openwrt-<commithash>-<timestamp> 所以 restoreKeys 中的 cache-openwrt 一定会命中缓存 也就是说不管工具链的commithash有没有发生变化,只要缓存存在就一定会命中,那这个还有什么意义呢?

建议将 restoreKeys 只添加一个 restoreKeys = ['cache-openwrt-<commithash>'] 这样可以根据工具链的 commithash 去命中缓存

bob-zebedy avatar Nov 15 '21 02:11 bob-zebedy

命中了缓存不影响源文件出现变动、也会重新编译变动的那部分呀。 keyString 其实主要还是更新缓存用的,比如如果不用ccache,那么keyString就不会加一个时间戳,多次编译时这个keyString没有变化,Post cache这一步就会自动跳过更新缓存。

stupidloud avatar Nov 15 '21 16:11 stupidloud

感谢答疑,还有一个问题,GitHub Action 的缓存是每个仓库5G还是一个人一共5G

bob-zebedy avatar Nov 16 '21 10:11 bob-zebedy

应该是账号5g

stupidloud avatar Nov 16 '21 15:11 stupidloud