We wanted to use Aerospike as a cache for deduplication of event ids, with a predefined TTL.
Our use case is very simple: For every event that we receive, we would like to check if this event id exists in the cache or not. If it does, we would want to reset the TTL (touch the record) and mark this event as a fraud in our application, else we would like to do a put operation to insert this id.
What we are planning to do is the following:
(i) Configure a single record namespace since the only thing we wish to store is the id. We will use the event ids as the keys, and store NullValue as the corresponding value. (Since we really don't need anything other than the key value).
(ii) For the deduping check, we will first check client.exists() and then do a put operation with RecordExistsAction.REPLACE in the write policy (since this is optimized for performance). Both of these operations will be called in an operate() block for atomicity.
But we had a few queries regarding the following:
(i) Regarding the operate block, this check and set transaction that we wish to do seems to be a very common use case. Is there an API that achieves this in a cleaner manner? (We could not find anything)
(ii) Is it absolutely necessary to have even a single bin? We only wish to store the keys and no corresponding value. I realize that the key value isn't ever stored and Aerospike only stores the digest but since exists() is the only thing we care about, is there any way to get rid of the extra bin storage overhead?
Thank you!