UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'oaCPmxCwI3GISFU2PH3K7af1imqnAtUNa+BYvY+sevM=' 
WHERE 
  key_id = '5d444dc5e802af6203ad70c7d3487fa59b8d65c1de68d87a597fbf4a488afa3a' 
  AND (
    token = 'oaCPmxCwI3GISFU2PH3K7af1imqnAtUNa+BYvY+sevM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00048