Im running Rails 4.2.7 on Ubuntu 14.04. I wrote the following method for caching some data (preventing getting into my PostGres 9.5 database) ...
class Country < ActiveRecord::Base has_many :states def self.cached_find_by_iso(iso) Rails.cache.fetch("#{iso}") do find_by_iso(iso) end end end
However, even after running rake tmp: cache: to clear and restart my server, I get this error when trying to call the above ...
Error during processing: Not a directory @ rb_file_s_rename - (/home/rails/myproject/tmp/cache/00020161104-1093-67j634, /home/rails/myproject/tmp/cache/001/000/) /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/fileutils.rb:528:in `rename' /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/fileutils.rb:528:in `block in mv' /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/fileutils.rb:1571:in `block in fu_each_src_dest' /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/fileutils.rb:1587:in `fu_each_src_dest0' /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/fileutils.rb:1569:in `fu_each_src_dest' /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/fileutils.rb:517:in `mv' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/file/atomic.rb:36:in `atomic_write' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/cache/file_store.rb:83:in `write_entry' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/cache/strategy/local_cache.rb:115:in `write_entry' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:391:in `block in write' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:547:in `block in instrument' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:166:in `instrument' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:547:in `instrument' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:389:in `write' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:588:in `save_block_result_to_cache' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:299:in `fetch' /home/rails/myproject/app/models/country.rb:5:in `cached_find_by_iso' /home/rails/myproject/app/services/all_events_guide_service.rb:84:in `block in process_page_data' /usr/local/rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/node_set.rb:187:in `block in each' /usr/local/rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/node_set.rb:186:in `upto' /usr/local/rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/node_set.rb:186:in `each' /home/rails/myproject/app/services/all_events_guide_service.rb:45:in `process_page_data' /home/rails/myproject/app/services/abstract_import_service.rb:83:in `process_my_object_data' /home/rails/myproject/app/services/all_events_guide_my_object_finder_service.rb:103:in `block in process_my_object_link' /usr/local/rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/node_set.rb:187:in `block in each' /usr/local/rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/node_set.rb:186:in `upto' /usr/local/rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/node_set.rb:186:in `each' /home/rails/myproject/app/services/all_events_guide_my_object_finder_service.rb:82:in `process_my_object_link' /home/rails/myproject/app/services/abstract_my_object_finder_service.rb:29:in `block in process_data' /home/rails/myproject/app/services/abstract_my_object_finder_service.rb:28:in `each' /home/rails/myproject/app/services/abstract_my_object_finder_service.rb:28:in `process_data' /home/rails/myproject/app/services/run_crawlers_service.rb:18:in `block in run_all_crawlers' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/delegation.rb:46:in `each' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/delegation.rb:46:in `each' /home/rails/myproject/app/services/run_crawlers_service.rb:5:in `run_all_crawlers' /home/rails/myproject/app/controllers/my_objects_controller.rb:170:in `block in import'
How can I clear the cache and let my cached method get started properly?
Edit: I get the same error above with Deepak's suggestion, but here is the result of his answer ...
rails@mymachine :~/myproject$ rails console Loading development environment (Rails 4.2.7.1) 2.3.0 :001 > Rails.cache.clear => ["/home/rails/myproject/tmp/cache/assets"] 2.3.0 :002 > quit
Edit 2: Here is my config / environment.production.rb file. This is a production environment ...
Rails.application.configure do
source share