I’m currently using a sorted map with a timestamp as a key, and trying to enforce a limit using an atomic map operation, keeping the most recent items. Unfortunately there doesn’t seem to be a way to keep only last X elements in a sorted map. What I have done as a workaround is to use negative timestamp as the key, and then use removeByIndexRange.
It would be nice if there was either a way to set the sort ordering (e.g. ASCENDING, DESCENDING), or to allow negative indexes to be used by removeByIndexRange for this purpose, or a new method (e.g. removeByReverseIndexRange). Any of these options would allow for limit on last X items without changing the map key.