Ok I have been working my way around Memcache for the last few days, attempting to collate the most helpful articles I can find (Primarily from Stackoverflow)
I understand creating a value using a key in memcache and have read that correct/efficient key naming is important. The best way it seems to make a key unique is to use the $id. My question is how can I make a key unique without having the $id (if for example that $id is just auto incremented within my Mysqli database table)
An example of Memcache inserting and retrieving is the following:
$sql = "INSERT INTO products SET id = $id, name = $name";
// Run Insert Query Here using prepared statement
if (success === TRUE)
{
//set a key
$key = 'product_'.$id ;
$product = array('id' => $id, 'name' => $name);
$memcache->set($key, $product);
}
This I believe will work fine, but my question is how could I make the key unique if I do not have access to the $id? As I could use the name, but there is a possibility that two users could have the same name.
I hope this makes sense. Any help or guidance would be appreciated.