Search code examples
ruby-on-railscaching

can i read the contents of file_store cache file in rails?


We have a production app that is slowing down, one of the suspects is the file cache. Periodically, we are seeing gigantic file_store cache files, ex:

11044573 ./21D/AE1/menu_structure_5cb9b70e11e9b84ac9fa8412_super_admin

that leftmost number is the block size. If we clear cache and the app regenerates the same file, it's way smaller:

-rw-r--r-- 1 deploy deploy 19K Oct 23 17:27 ./21D/AE1/menu_structure_5cb9b70e11e9b84ac9fa8412_super_admin

(they're different formats b/c they were found with different commands but the first one is giant, the second one is 18K). Everything works fine, so we think there must be some weird thing where a ton of extra data is defectively being stored in a cache file. Is there a way see what's in there so we can debug why this is happening?

Thanks for any help, kevin


Solution

  • I dug through the rails source and here's the answer

    cache_file_path = "tmp/cache/your_cache_file"
    cache_entry = Marshal.load(File.read cache_file_path)
    cache_entry.value