Laravel Cache:如何识别向其写入数据的内容

最近,在我们使用Laravel 5.4的一个项目中,我们注意到一些数据正在 / storage / framework / cache / data </ code> - 我们正在使用文件缓存。 缓存中文件的内容如下: 1529533237i:1; </ code>。 全天在缓存中创建了几个文件,内容与此类似。 创建了很多文件,我们必须定期清理这个缓存,以免因运行inode而导致磁盘空间问题。</ p>

我知道使用文件缓存的替代方法是事物 像Redis或Memcache,但问题是,我们不确定缓存的数据是什么,或者项目的哪个组件正在缓存它。 我们确实使用了几个外部库,因此可能是众多外部库中的一个,但我们不确定是什么。 我已经查看了项目的所有配置文件,但无法识别显然控制数据缓存的任何内容。</ p>

是否有任何关于尝试识别哪一段代码的建议 写这些数据,以便我们可以更好地处理这些数据的缓存,无论它是什么?</ p>
</ div>



Recently, in one of our projects that use Laravel 5.4, we have noticed that some data is being cached in /storage/framework/cache/data - we are using file cache. The contents of the files in the cache are things like: 1529533237i:1;. Several files are created in the cache throughout the day with content similar to that. So many files are created that we have to clean this cache periodically in order not to run into disk space issues by running out of inodes.

I know that an alternative to using file cache are things like Redis or Memcache, but the issue is, we're not sure what is this data being cached or what component of the project is caching it. We do use several external libraries so it could be one of many, but we don't know for sure what. I've already looked into all configuration files of the project, but couldn't identify anything that is obviously controlling data caching.

Are there any recommendations on trying to identify which piece of code is writing this data so we can better handle the caching of this data, whatever it may be?


Laravel有几个事件。</ p>

创建一个侦听 Illuminate \ Cache \ Events \ KeyWritten </ code>事件的新侦听器。 您可以记录回溯以确切了解导致特定项目被缓存的内容。</ p>
</ div>



Laravel has several events that dispatch during caching.

Create a new listener that listens on the Illuminate\Cache\Events\KeyWritten event. You could log the backtrace to see exactly what leads to specific items being cached.

duanqiao9541 这就像一个魅力,非常感谢!
2 年多之前 回复
Csdn user default icon