0

I can't cache large ActiveRecord objects. With small ones it's ok:

sel = Car.select("id, `key`, value").limit(1000)
Rails.cache.write('miauuu', sel)
=> true

But if they get a bit larger:

sel = Car.select("id, `key`, value").limit(10000)
Rails.cache.write('miauuu', sel)
=> false

The size is not terribly high though:

ObjectSpace.memsize_of(sel)
=> 272

I'm using Dalli cache store:

Rails.application.config.cache_store
 => :dalli_store

I even ensured the max value should be large enough in production.rb has this:

config.cache_store = :dalli_store, { value_max_bytes: 2000000 }

And yet, I'm getting false here:

Rails.cache.write('miauuu', sel)
=> false

Any idea why? Thanks

valk
  • 9,363
  • 12
  • 59
  • 79

1 Answers1

0

Make sure to also update the Memcached config on the server, usually located in /etc/memcached.conf with the correct setting, in your case:

-I 2M
eoy
  • 452
  • 4
  • 15