UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ESgFwAw+Mmpd058PTLxUBD7dtRpP+tMDEq58PBXvCHU=' 
WHERE 
  key_id = '77deffa0c5aab681d70c30506733c0810251eb13914912e6521c1cff30790ca4' 
  AND (
    token = 'ESgFwAw+Mmpd058PTLxUBD7dtRpP+tMDEq58PBXvCHU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00045