Removing records from kv that exceed the limit #6418
Replies: 3 comments
-
MaxMsgsPerSubject will do what you want and that is the default when creating a KV. You can use history to ask for N number of records per subject, e.g. 100. |
Beta Was this translation helpful? Give feedback.
-
My apologies for the lack of attention! Streams do have more options, and MaxMsgsPerSubject is exactly what I need. Thank you very much! |
Beta Was this translation helpful? Give feedback.
-
Maybe I was a bit hasty. Besides MaxMsgsPerSubject I saw the MaxMsgs option, and it seemed right to me. But then I realized that, for example, a message about deleting a non-existent record would displace an existing record, and I would lose useful data. Then I tried MaxMsgsPerSubject, but as far as I understand, this option sets the limit within one key, not KV. Just an example to demonstrate:
Could you give me an example of how MaxMsgsPerSubject could solve my problem? |
Beta Was this translation helpful? Give feedback.
-
Hello!
Please tell me if there is a way to remove records from kv that exceed the set limit? For example, I want to store 100 records in kv. As soon as the 101st record is added, it should displace the oldest one, as it is done in the LRU cache. I think this is a useful option.
I could find outdated records myself, but in this case I cannot guarantee that the oldest record will be removed, since after receiving it, it can be immediately updated by another user. In this unpleasant case, I will remove the current record with useful information.
I could also remove based on revision. However, you can't remove from kv based on revision, only from the stream. But I also can't remove records from the stream created with kv, since, apparently, you can't remove records directly from system streams.
At the moment, I don't see a beautiful solution to this problem. Please tell me if you have any advice. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions