Skip Menu |

This queue is for tickets about the Cache-Memcached CPAN distribution.

Report information
The Basics
Id: 28095
Status: open
Priority: 0/
Queue: Cache-Memcached

People
Owner: Nobody in particular
Requestors: sugi [...] nemui.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.23
  • 1.29
Fixed in: (no value)



Subject: [PATCH] Suggest: UTF8 flag support
Currently, Cache::Memcached lost utf8 flag when treat scalar values. (If use only references, the flag will be kept by Storable.) I wrote a patch and test to keep utf8 flag of scalar values. Please consider to merge the patch. Thanks,
Subject: support-utf8-flag.diff
diff -Nur Cache-Memcached-1.23.old/lib/Cache/Memcached.pm Cache-Memcached-1.23/lib/Cache/Memcached.pm --- Cache-Memcached-1.23.old/lib/Cache/Memcached.pm 2007-06-20 05:49:27.000000000 +0900 +++ Cache-Memcached-1.23/lib/Cache/Memcached.pm 2007-07-11 18:38:51.000000000 +0900 @@ -16,6 +16,7 @@ use IO::Handle (); use Time::HiRes (); use String::CRC32; +use Encode; use Errno qw( EINPROGRESS EWOULDBLOCK EISCONN ); use Cache::Memcached::GetParser; use fields qw{ @@ -30,6 +31,7 @@ # flag definitions use constant F_STORABLE => 1; use constant F_COMPRESS => 2; +use constant F_UTF8 => 4; # size savings required before saving compressed value use constant COMPRESS_SAVINGS => 0.20; # percent @@ -456,6 +458,8 @@ local $Carp::CarpLevel = 2; $val = Storable::nfreeze($val); $flags |= F_STORABLE; + } elsif (Encode::is_utf8($val)) { + $flags |= F_UTF8; } my $len = length($val); @@ -654,6 +658,9 @@ delete $ret->{$k}; } } + if ($flags & F_UTF8) { + Encode::_utf8_on($ret->{$k}); + } } }; diff -Nur Cache-Memcached-1.23.old/t/utf8flag.t Cache-Memcached-1.23/t/utf8flag.t --- Cache-Memcached-1.23.old/t/utf8flag.t 1970-01-01 09:00:00.000000000 +0900 +++ Cache-Memcached-1.23/t/utf8flag.t 2007-07-11 18:41:10.000000000 +0900 @@ -0,0 +1,29 @@ +# -*-perl-*- + +use strict; +use Test::More tests => 12; +use Cache::Memcached; +use Encode q/is_utf8/; + +my $testaddr = "127.0.0.1:11211"; +my $memd = Cache::Memcached->new({ + servers => [ $testaddr ], + namespace => "Cache::Memcached::t/$$/" . (time() % 100) . "/", +}); + +my $u_str = "\x{99f1}\x{99dd}"; +my $a_str = "ASCII"; +my $b_str = "\xe9\xa7\xb1\xe9\xa7\x9d"; + +ok(is_utf8($u_str), "check utf8 capability"); +ok(!is_utf8($a_str), "check utf8 capability"); +ok(!is_utf8($b_str), "check utf8 capability"); +ok($memd->set("u", $u_str), "set utf8"); +ok($memd->set("a", $a_str), "set ascii"); +ok($memd->set("b", $b_str), "set binary"); +is($memd->get("u"), $u_str, "get utf8"); +is($memd->get("a"), $a_str, "get ascii"); +is($memd->get("b"), $b_str, "get binary"); +ok(is_utf8($memd->get("u")), "check flag of getted utf8 value"); +ok(!is_utf8($memd->get("a")), "check flag of getted ascii value"); +ok(!is_utf8($memd->get("b")), "check flag of getted binary value");
Hello, is the package being maintained? It has been several years and several releases since the report, and utf-8 is still broken in 1.29 as of today. The above patch still applies with some fuzz, and fixes the problem.
On Wed Aug 10 09:47:23 2011, YENYA wrote: Show quoted text
> Hello, is the package being maintained? It has been several years and > several releases since the report, and utf-8 is still broken in 1.29 as > of today. > > The above patch still applies with some fuzz, and fixes the problem.
I think this bug tracker just isn't used. You might want to bring this up on the mailing list: http://groups.google.com/group/memcached