I ‘concat’ an id of just loaded image into mysql user record like this.
Userid … Photos_ids
12 1 2 5 7
And this photo_id should be unique. (To create unique file name). Now I get a current last id from memcache. But it's not really safely, as far as I understand.
It there any other ideas? (I do not add any other records into db, so PRIMARY KEY can be used only if I'd add some else special table for this... It's not a good idea).