Memcached issue with Rails 3. Object not deserialized a second time

I have a problem with memcached in Rails 3

Below in my controller

@last_post = Rails.cache.fetch('last') {Post.last}

From the view I call @last_post.title

The first time the view is loaded, the title of the last message is displayed. After updating the view, I get an errorundefined method 'title' for #<String:0x8007ae0>

It seems that the object is not deserializing a second time.

Am I doing something wrong? What can I do to fix this? (Ruby 1.8.7, Rails 3.0.1)

Thank!

+3
source share
2 answers

, Marshal.load, , Rails.cache.fetch, - Marshal.load, Rails (undefined /)

,

require_dependency 'post'

, ,

+2

! , development.rb, , . Aka development.rb

config.cache_store = :dalli_store

+1

Source: https://habr.com/ru/post/1775362/


All Articles