In our service, we predominantly do not use blind writes. We encountered a bug in the user code where we read an object in one transaction and saved it in another without a preliminary read. As a result, we ended up with an incorrect value in the database.
It's difficult to protect against such issues, however, an optional check can be added in the InMemoryRepository before saving: if the object is present in the database, we check the cache, and if the required object is not there, we fail. There are several problems here:
In our current implementation, we often use readAll(), so we cannot rely solely on the storage output.
Relying on the standard cache is not feasible, as it does not always contain all read objects. A custom cache is needed.
We need to consider how to add exceptions for cases where blind writing is justified. For example, adding a wrapper similar to the one in FullScanDetector.
In our service, we predominantly do not use blind writes. We encountered a bug in the user code where we read an object in one transaction and saved it in another without a preliminary read. As a result, we ended up with an incorrect value in the database.
It's difficult to protect against such issues, however, an optional check can be added in the InMemoryRepository before saving: if the object is present in the database, we check the cache, and if the required object is not there, we fail. There are several problems here: