Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.29
Fixed in: (no value)



Subject: Support for regexp objects
Currently it's not possible to store regexp objects using Cache::Memcached. Here's a sample script: #!/usr/bin/perl use Test::More qw(no_plan); use Cache::Memcached; diag "Cache::Memcached::VERSION: $Cache::Memcached::VERSION"; my $memc = Cache::Memcached->new({servers => ["127.0.0.1:11211"]}); my $rx = qr{bla}; $memc->set("test.rx", $rx); my $rx_got = $memc->get("test.rx"); diag $rx_got; like "bla", $rx; like "bla", $rx_got; $memc->delete("test.rx"); __END__ Depending on the perl (or Storable.pm?) version, the result is either an error when calling ->set: # Cache::Memcached::VERSION: 1.29 # Storable::VERSION: 2.22 # perl version 5.012000 Can't store REGEXP items at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/_freeze.al) line 339, at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/nfreeze.al) line 327 ... or no error when storing in memcached, but the deserialized regexp object is wrong: # Cache::Memcached::VERSION: 1.28 # Storable::VERSION: 2.15 # perl version 5.008008 # Regexp=SCALAR(0xbfd1be0) ok 1 not ok 2 # Failed test in /tmp/mc.pl at line 12. # 'bla' # doesn't match 'Regexp=SCALAR(0xbfd1be0)' 1..2 # Looks like you failed 1 test of 2. At least it would be good to document that storing regexp objects does not work with Cache::Memcached. Maybe it would be not too hard to support regexp objects by doing a stringification when serializing and putting the string into a qr{...} when deserializing. Regards, Slaven
This is unlikely to ever get fixed in Cache::Memcached itself. We could consider adding support for Data::Dumper serialization or something, but the limitation right now lies in Storable. I don't want to add a hack to Cache::Memcached to fix a problem with Storable, because the hack may turn out worse than just saying we don't support it. On Tue Feb 01 04:47:47 2011, SREZIC wrote: Show quoted text
> Currently it's not possible to store regexp objects using > Cache::Memcached. Here's a sample script: > > #!/usr/bin/perl > > use Test::More qw(no_plan); > use Cache::Memcached; > diag "Cache::Memcached::VERSION: $Cache::Memcached::VERSION"; > my $memc = Cache::Memcached->new({servers => ["127.0.0.1:11211"]}); > my $rx = qr{bla}; > $memc->set("test.rx", $rx); > my $rx_got = $memc->get("test.rx"); > diag $rx_got; > like "bla", $rx; > like "bla", $rx_got; > $memc->delete("test.rx"); > > __END__ > > Depending on the perl (or Storable.pm?) version, the result is either an > error when calling ->set: > > # Cache::Memcached::VERSION: 1.29 > # Storable::VERSION: 2.22 > # perl version 5.012000 > Can't store REGEXP items at ../../lib/Storable.pm (autosplit into > ../../lib/auto/Storable/_freeze.al) line 339, at ../../lib/Storable.pm > (autosplit into ../../lib/auto/Storable/nfreeze.al) line 327 > ... > > or no error when storing in memcached, but the deserialized regexp > object is wrong: > > # Cache::Memcached::VERSION: 1.28 > # Storable::VERSION: 2.15 > # perl version 5.008008 > # Regexp=SCALAR(0xbfd1be0) > ok 1 > not ok 2 > # Failed test in /tmp/mc.pl at line 12. > # 'bla' > # doesn't match 'Regexp=SCALAR(0xbfd1be0)' > 1..2 > # Looks like you failed 1 test of 2. > > At least it would be good to document that storing regexp objects does > not work with Cache::Memcached. Maybe it would be not too hard to > support regexp objects by doing a stringification when serializing and > putting the string into a qr{...} when deserializing. > > Regards, > Slaven