Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails low level cache not working in development mode

I've configured the development.rb file like this:

# Enable/disable caching. By default caching is disabled.
config.action_controller.perform_caching = true

config.cache_store = :memory_store
config.public_file_server.headers = {
  'Cache-Control' => 'public, max-age=172800'
}

(erased the default config that checks for a file just to test)

Then I open a rails console to test this but it does not seem to be working:

[1] pry(main)> Rails.cache.write("asd", "asd")
=> true
[2] pry(main)> Rails.cache.read("asd")
=> nil

I've managed to make it work a couple of days ago, but now it is not working.

A I missing something?

like image 544
fedest Avatar asked Feb 19 '19 16:02

fedest


2 Answers

I fixed it by restarting spring. Doing

> spring stop
Spring stopped.
> spring start

does the trick.

Note: when starting spring again, it may fail, but it'll work anyway.

like image 140
fedest Avatar answered Sep 26 '22 16:09

fedest


In rails 6.1.4

run rails dev:cache to toggle caching in development

like image 32
Suhas C V Avatar answered Sep 24 '22 16:09

Suhas C V