User:AnomieBOT/source/AnomieBOT/API/Cache/Memcached.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: SourceUploader/WikiPod.pm: * Direct section 3perl links to perldoc. AnomieBOT::API::Cache, AnomieBOT::API::Cache::Memcached: * Fix docs.
AnomieBOT (talk | contribs)
Updating published sources: AnomieBOT::API::Cache::Memcached: * Remove compat code, Digest::CRC is installed now.
Line 12:
use Socket;
use IO::Socket;
use Digest::CRC ('crc32');
use Crypt::GCrypt;
use Digest::SHA ();
use IO::Compress::Gzip ();
use IO::Uncompress::Gunzip ();
 
# Work around that neither CRC module is currently installed in Tool Labs.
# Once one is, change this code to just use it.
eval { require String::CRC32; String::CRC32->import('crc32'); };
eval { require Digest::CRC; Digest::CRC->import('crc32'); } if $@;
if($@){
my @crc32_table = ();
for(my $i = 0; $i < 256; $i++) {
my $x = $i;
for(my $j = 0; $j < 8; $j++) {
if ($x & 1) {
$x = ($x >> 1) ^ 0xedb88320;
} else {
$x = $x >> 1;
}
}
$crc32_table[$i] = $x;
}
 
# Odd syntax so Perl doesn't pick up the sub at compile time.
*crc32 = sub {
my $crc = 0xffffffff;
foreach my $b (unpack('C*', $_[0])) {
$crc = (($crc >> 8) & 0xffffff) ^ $crc32_table[($crc ^ $b) & 0xff];
}
return $crc ^ 0xffffffff;
};
}
 
use constant {