perl API : idsession CRC32 vs ord function for test Apache::Session

eric GERMAN eric.german@cp.finances.gouv.fr
Tue, 27 Jul 2004 10:38:10 +0200


Hi , I keep  trying memcached +  perl API +  apache::Session

the keys are  like this :

stats cachedump 7 4
ITEM 5ee71b9d6c06f42898a8854d9b085ea5 [43 b; 1090916693 s]
ITEM b37ba939c5fdf9b47af27c4a5539c3b5 [43 b; 1090916693 s]
ITEM df1506343dd4c87ef24af32b326ee19c [43 b; 1090916693 s]
ITEM 1ff0a0b1df2c4f47be6eb5c2f604bb5e [43 b; 1090916693 s]

(generated by Apache::Session:Generate::MD5.pm  function)

with the original API perl (using ord function) with 2  servers my stats 
result are :

[root@portable memcached-1.1.11]# telnet  10.75.237.156 11212 
Trying 10.75.237.156...
Connected to 10.75.237.156 (10.75.237.156).
Escape character is '^]'.
stats items
END
quit
Connection closed by foreign host.
[root@portable memcached-1.1.11]# telnet  10.75.237.156 11211
Trying 10.75.237.156...
Connected to 10.75.237.156 (10.75.237.156).
Escape character is '^]'.
stats items
STAT items:7:number 99
STAT items:7:age 41
END

==>  Only  bucker 0  is using .

When I  use  String::CRC32  I have :



[root@portable memcached-1.1.11]# telnet  10.75.237.156 11212
Trying 10.75.237.156...
Connected to 10.75.237.156 (10.75.237.156).
Escape character is '^]'.
stats items
STAT items:7:number 43
STAT items:7:age 25
END
quit
Connection closed by foreign host.
[root@portable memcached-1.1.11]# telnet  10.75.237.156 11211
Trying 10.75.237.156...
Connected to 10.75.237.156 (10.75.237.156).
Escape character is '^]'.
stats items
STAT items:7:number 56
STAT items:7:age 41
END

my  diff
[root@portable Cache-Memcached-1.0.12]# diff Memcached.pm  
Memcached.pm.good
15c15
<
---
 > use String::CRC32;
602,604c602,605
<     foreach (split //, shift) {
<         $hash = $hash*33 + ord($_);
<     }
---
 > $hash = (crc32(shift) >> 16) & 0x7fff;
 > #    foreach (split //, shift) {
 > #        $hash = $hash*33 + ord($_);
 > #    }


thanks
eric german