Fetches key id on insertion or on it already being found.