In OL4 (or, I guess, any version >=3.0), all features have an undefined id unless it is set by any mean. They do have, however, an ol_uid value (as far as I could understand, all ol objects have such property), that seems a "random" number set automatically by openlayers. In order to store feature styles in memory, it is safe to use this variable as a map index? I am doing it already, but want to be sure that there's "no chance" of collision.
As they said in the comment, there'll be no collision.
Unique IDs are generated as a strictly increasing sequence.