I currently have a small database updater that'll insert/update a users IP address every time they enter the server. Since this is ran on an interval which empties a cache every 2 seconds, i really want to find a good quick method to update the table.
Here is what i currently use (MySQL only sadly :( )
INSERT INTO `iban_ipcache` VALUES (
'" + PlayerName + "',
'" + UpdatedTime + "', //This is just System.getCurrentMills
'" + PlayerIP + "')
ON DUPLICATE KEY UPDATE VALUES (
ip='" + PlayerIP + "',
time='" + System.currentTimeMills() + "';"
-- This was modifed so it can be read more easily, the query also uses ` instead of '--
The query works perfectly but.. Well i have to change the IP AND the time no matter what. So if the IP doesn't actually change, it'll still attempt to alter it. The time is used for both GUI reasons, and cross server updating reasons. So basically every time an old user logs in, the database will treat them like they just got a new IP.
My question is, is there any way to possibly check if BOTH the key and IP are the same without having to use Select?