How to increase memcache slab size above 1MB with dalli and Rails?

佐手、 提交于 2019-12-23 20:28:25

问题


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.


回答1:


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 }


来源:https://stackoverflow.com/questions/37352553/how-to-increase-memcache-slab-size-above-1mb-with-dalli-and-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!