Hi I’m Integrating memcache in my codeigniter application,
My query change on the user selected values. some thing like this
$sql='select * from user where user_name="'.$name.'" and location='".$location."'";
$result = $this->memcached_library->get(md5($sql));
if(!$result ){
/* execute query and get $result */
$this->memcached_library->add(md5($sql), $result );
}else{
return $result;
}
This is my approach to handle the keys for each different query. But I have heard some where that md5() is not always unique.?
1> Is md5() always unique?
2> if md5() is not unique than what shoud be the other option….
3> what about crc32() is that unique??
Thanks….
A. Your SQL is wrong it should be
B. You code might have errors since MD5 is case sensitive
See
Output
Better Approach us using
strtolowerC, Is MD5 unique
D. Better option is using
sha1