module EncodedKeyCacheBehavior

quails.lighthouseapp.com/projects/8994/tickets/6225-memcachestore-cant-deal-with-umlauts-and-special-characters The error is caused by character encodings that can't be compared with ASCII-8BIT regular expressions and by special characters like the umlaut in UTF-8.

Public Instance Methods

test_common_utf8_values() click to toggle source
# File activesupport/test/cache/behaviors/encoded_key_cache_behavior.rb, line 20
def test_common_utf8_values
  key = "\xC3\xBCmlaut".dup.force_encoding(Encoding::UTF_8)
  assert @cache.write(key, "1", raw: true)
  assert_equal "1", @cache.read(key)
  assert_equal "1", @cache.fetch(key)
  assert @cache.delete(key)
  assert_equal "2", @cache.fetch(key, raw: true) { "2" }
  assert_equal 3, @cache.increment(key)
  assert_equal 2, @cache.decrement(key)
end
test_retains_encoding() click to toggle source
# File activesupport/test/cache/behaviors/encoded_key_cache_behavior.rb, line 31
def test_retains_encoding
  key = "\xC3\xBCmlaut".dup.force_encoding(Encoding::UTF_8)
  assert @cache.write(key, "1", raw: true)
  assert_equal Encoding::UTF_8, key.encoding
end