We want to use Aerospike as a write-aside cache. We need to be careful not to store data that is stale due to concurrent changes. What is the best way to set a single value into a key and assert the key has not changed since you last read it? We are using the .NET client.
I can imagine a possible implementation looks something like, where each line is atomic operation:
- “Touch” the key to increment and retrieve a new generation code
- Modify/persist data in source (an RDBMS)
- Store source data in cache IFF current generation code matches value from step 1
Is this the right approach? If so, how do I do that in the .NET client?