By default, optimistic concurrency checks are turned off, which means that changes made outside our session object will be overwritten if the SaveChangesAsync is called.
Checks can be turned on by setting the UseOptimisticConcurrency property from the Advanced session operations to true and may cause the ConcurrencyExceptions to be thrown.
The above example shows how to enable optimistic concurrency for a particular session. However, that can be also turned on globally, that is for all opened sessions, by using the DefaultUseOptimisticConcurrency convention.
store.Conventions.DefaultUseOptimisticConcurrency = true;
using (IAsyncFilesSession session = store.OpenAsyncSession())
bool isSessionUsingOptimisticConcurrency = session.Advanced.UseOptimisticConcurrency; // will return true
You can also force the concurrency check by explicitly passing an Etag parameter to the RegisterXXX method.