I would like to know if it is possible to lock dynamic data store avoiding that several threads could access the same store at the same time.
My idea is to implement a counter and stores its value using DDS. Every time I create a block of type T, I increment the counter. The problem is that if I create two blocks at the same time, the counter would increase only 1, instead of 2 units.
One approach is to define a repository that takes care of the updates towards DDS. Then if you scope your repository as Singleton in the IOC container you can have your own lock handling within your repository.
Thats all good until you run on more than one server. I guess you could write a lock to Redis but isn't this a feature that should be part of the API? Afterall in the API you can use transactions.