Pattern

Selector Recreation Tension

selector-function-recreation

how to reset this key when value reaches to 25k in a thread safe way. — Multiple threads are writing in the file concurrently. Tension: any number shall be skipped or give duplicate value to thread. | Multiple threads are writing in the file concurrently. — I need to persist this counter because if process get restarted then it counter should start from last count. Tension: I hope there wont be a case when any number shall be skipped or give duplicate value to thread. Outcome: how to reset this key when value reaches to 25k in a thread safe way. | In addition to the suggestion of using a Lua script, you could stick to your solution of using INCR — since redis is single threaded so this will be thread safe. Tension: how to reset this key when value reaches to 25k in a thread safe way. Outcome: simulate the reset of the counter on the client side by taking the remainder of the returned value.