Getting 'Last 5' Readings - Ring Circle Buffers with Topic-awareness

I'm trying to create analysis based upon 'Last 5' payloads per Device.
The Last 5 payloads can be documents, not just numbers.

There are many Buffers (Ring, Circle and Array) and not all of these are numeric only.
But I cannot find anything that is Topic-aware.

Although Smooth internally implements buffering for numerics that is Topic-aware, but it is no good for documents, and cannot be generalized as it is sending on numbers.

Before I write something from scratch, based upon code of the above, can anyone suggest a pre-built buffer that matches my need?