Reputation: 13581
I'm getting a rails error because it's expecting UTF-8, memcached is converting my string into ASCII-8BIT. I'm caching currency data including the symbol to prevent unnecessary hits to the DB.
My method here:
def self.find_symbol(currency)
Rails.cache.fetch(currency, :expires_in => 1.week) { Currency.find_by_code(currency).symbol }
end
The part being cached is in UTF-8.
Currency.find_by_code(currency).symbol
However when it comes out of the method is in ASCII-8BIT and looks like "\xE2\x82\xAC"
I'm unsure how memcache handles strings, if I should/can force it so save the string as UTF, (no idea why it converts it) or force it back to UTF when I pull it out?
Upvotes: 1
Views: 2030
Reputation: 13581
Upgraded to rails 3.0.7 and that fixed it.
As of Dalli 1.0.3 and Rails 3.0.7 it now works fine.
Upvotes: 1
Reputation: 14149
I'm pretty sure memcached just handles the key values as straight bytes and isn't aware of character sets.
This would suggest that this is some kind of rails issue.
Upvotes: 2