Cache translation
(Raw wiki text)
O [http://trac.globalize-rails.org/trac/globalize/wiki Globalize], plugin que o
Motiro utiliza para tradução, armazena o texto em banco de dados (sem nenhum
tipo de caching por padrão). Talvez isto esteja fazendo com que as respostas
sejam mais lentas do que precisam ser.
Uma das soluções (se isto realmente for um problema, claro) para isso é implantar
um mecanismo de caching das traduções quando elas forem carregadas a partir do
banco de dados. Isto pode ser feito através de memcached ou outra solução
parecida.
Outra solução é eliminar totalmente o uso do Globalize. Ele poderia ser
substituído por alguma outra solução pré-cozida disponível em Ruby/Rails ou uma
receita de casa. Pode-se armazenar em memória todo o texto a ser traduzido
quando o servidor da aplicação fosse iniciado. Depois disso todas as consultas
seria a memória diretamente. Esta solução tem a vantagem bônus de agilizar o
processo de instalação.
Há um
[http://wiki.rubyonrails.org/rails/pages/InternationalizationComparison comparativo]
com algumas outras soluções para tradução na wiki de Rails.
--- en -------------------------------------------------------------------------
[http://trac.globalize-rails.org/trac/globalize/wiki Globalize], the plugin that
Motiro uses for internacionalization, stores text on a database (with no
caching by default). Maybe this is making the responses slower that they need to
be.
One of the possible solutions (if this is really a problem, of course) is to put
a caching mechanism in place. Translations could be stored on faster memory once
they get loaded from the database. This can be done using memcached ou another
similar solution.
Another solution is to avoid using Globalize completely. It could be changed for
another pre-packaged Ruby/Rails solution or a home made one. Translation strings
can be stored in-memory when the application server is started (or on the first
request). After that all queries would hit memory directly. This solution has the
hidden bonus advantage of reducing the installation time.
There is a
[http://wiki.rubyonrails.org/rails/pages/InternationalizationComparison comparison]
of some other solutions for translation on the Rails' wiki.