Rails.cache and un-dumpable (Marshal) structures: how to cache? (on the example flickraw-response)
-
26-09-2019 - |
Question
i want to Rails.cache a flickraw response (this is applicable to other un-dumpable structures as well) with memcached as follows:
@flickr = Rails.cache.fetch('flickr_sets', :expires_in => 1) { flickr.photos.getRecent }
the obvious error is
TypeError: singleton can't be dumped
i read a good post on that problem by zilkey, who suggests building a new dump method for that case.
http://zilkey.com/2008/7/5/rails-cache-memcached-development-mode-and-offline-cache-invalidation
my questions are: what would be the right approach to cache that kind of objects? should i write my own dump method? wouldn't it be possible to save the object in the cache with flickr.photos.getRecent.to_s as a String and then somehow reload it? any ideas?
Solution
i asked your question on the github tracker, since i am also very interested in achieving this. ( see https://github.com/hanklords/flickraw/issues#issue/16 )
hanklords seems to have fixed this in a current commit! great thing, i am trying to implement this in a current app of mine. can you maybe also test it, z3cko? https://github.com/hanklords/flickraw/commit/d09db4c5549e72b42eefbf1ea5c98f95bd1bd3d9