We currently use MD5 to hash keys that we want to lookup in memcached.
A basic example being:
$sql = "SELECT * FROM articles WHERE id = 1";
$key = md5($sql);
if (!$results = $memcache->get($key)) {
$results = $db->query($sql);
$memcache->set($key, $results);
}
The key sizes are all 32 bytes as it uses MD5 to hash the key.
We are considering using crc32 instead to hash the key to save memory e.g:
$key = hash('crc32', $sql);
This generates a key of only 8 bytes.
Is this a good enough solution to replace MD5 as the key hash? Is there an increase in potential collision's with keys?