如何使用dalli和Rails将Memcache slab的大小增加到1MB以上? [英] How to increase memcache slab size above 1MB with dalli and Rails?
问题描述
我正在使用Ruby on Rails和dalli gem通过memcache进行缓存.
I'm using Ruby on Rails and dalli gem to do caching with memcache.
默认值(即键值存储中的值,也称为平板)的最大大小为1MB.
The default value (value as in key-value store, aka slab) max size is 1MB.
我想将其增加到2MB.
I would like to increase this to 2MB.
dalli的文档说:
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.
使用memcached
的-I
选项,如何指定2MB?是-I2还是-I2000? (文档尚不清楚)
With the -I
option of memcached
, how do I specify 2MB? Is it -I2 or -I2000? (the documentation isn't clear on this)
对于达利宝石,我在environments/development.rb
config.cache_store = :dalli_store
我没有明确提及Dalli :: Client.new
那么如何设置value_max_bytes
?
I don't have explicit mention of Dalli::Client.new
So how can I set the value_max_bytes
?
我看过相关的内容关于stackoverflow的问题,似乎我需要安装rack-cache gem.这有必要吗?
I've looked at the related question on stackoverflow, it seems that I need to install the rack-cache gem. Is this necessary?
谢谢.
推荐答案
使用以下命令启动memcached
:
memcached -p 11211 -I2m
在Rails环境文件(例如config/environments/production.rb)中,使用以下语法:
In Rails environment file, eg config/environments/production.rb, use the following syntax:
config.cache_store = :dalli_store, { value_max_bytes: 2000000 }
这篇关于如何使用dalli和Rails将Memcache slab的大小增加到1MB以上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!