Main classes are ConcurrentTransactionalKeyValueStore and SynchronousTransactionalKeyValueStore.
SynchronousTransactionalKeyValueStore is only for illustration purposes to show how it fails in multithreading case
To run launch Main.kt main
function
While working in concurrent environment I assumed that transaction consistency was the most important factor. To correctly handle it I've chosen Serializable isolation level. If one thread transaction is active, all other operations will be locked until it completes by COMMIT or ROLLBACK
- Track operations instead of whole map copy for transactions to reduce memory usage. Will complicate get and count implementations a bit
- Cache COUNT operations in LRU cache to have O(1) complexity for frequent counts
- Use more relaxed transaction isolation level to improve multi-thread performance