Can I get another kv pair in rocksdb when I do CompactionFilter

I want to use the CompactionFilter to do ttl, however in my case, the key value pair shouldn’t start timing when they are created, but should be in some time after the kv pair is created. Currently I put a kv pair to store the time, and I want to use this time to do corresponding kv pair ttl delete.
How can I process this case?

you can use the timestamp feature (User defined Timestamp (Experimental) · facebook/rocksdb Wiki · GitHub) to insert the timestamp into the key and then apply your logic in a customized compaction filter (Compaction Filter · facebook/rocksdb Wiki · GitHub) to remove the keys when required. bare in mind that the keys will not be removed if no compaction is triggered on them so you might want to call periodic compaction.

1 Like