开发者

Using Redis for as a Rails Internationalization Backend

I recently translated a website into a Rails I18n YAML file and the file itself is quite big (30 kbs+). I'm not sure how the simplebackend is hand开发者_Python百科led, but from my understanding, each instance of the rails application will hash that YAML file into its backend which is stored in memory. It seems like a typical hash array in Ruby can go upwards from 100 bytes in size, so having over 500 translation hash keys with values may amplify the total memory usage quite a bit. Maybe I'm being paranoid, but I think it would be better to use another I18n backend such as Redis to store the translations.

Is my logic here correct? Should I make the change?


Yes, you should, for exactly the reasons you specified. YAML is great for testing your application, but it doesn't work very well for production purposes (high memory usage, slow writing to file, etc). Redis is a great alternative and plugs directly into the I18n gem.

See this Railscast for most details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜