3

I'm using Ruby on Rails and dalli gem to do caching with memcache.

The default value (value as in key-value store, aka slab) max size is 1MB.

I would like to increase this to 2MB.

The documentation of dalli says:

value_max_bytes: The maximum size of a value in memcached. Defaults to 1MB, this can be increased with memcached's -I parameter. You must also configure Dalli to allow the larger size here.

With the -I option of memcached, how do I specify 2MB? Is it -I2 or -I2000? (the documentation isn't clear on this)

For the dalli gem, I have, in environments/development.rb

config.cache_store = :dalli_store

I don't have explicit mention of Dalli::Client.new So how can I set the value_max_bytes?

I've looked at the related question on stackoverflow, it seems that I need to install the rack-cache gem. Is this necessary?

Thank you.

Community
  • 1
  • 1
Zack Xu
  • 11,505
  • 9
  • 70
  • 78

1 Answers1

5

Start the memcached with the command:

memcached -p 11211 -I2m

In Rails environment file, eg config/environments/production.rb, use the following syntax:

config.cache_store = :dalli_store, { value_max_bytes: 2000000 }
Zack Xu
  • 11,505
  • 9
  • 70
  • 78