I wonder if you could sidestep the inefficiencies of storing ID's for every character by using redis streams to store the characters with id's "represented as delta-compressed macro nodes that are linked together by a radix tree" where the ids are
"monotonically incrementing and has two parts: <time>-<counter>. The time is in milliseconds and the counter increases for entries generated in the same milliseconds"
This would seem to avoid clashes and also compress the identifier storage in an efficient way.
This would seem to avoid clashes and also compress the identifier storage in an efficient way.
https://antirez.com/news/128