Continulusly recording audio in fixed size buffer

Ten years ago I had casio digital camera with PastMovie function which would record continuously in a 6 second buffer. When something interesting happens you have up to 6 seconds to press record button and camera would take 6 seconds from the buffer and continue recording from that point.
I would like to make something like that just for audio, but if something like that already exists it would be even better. Cost should be minimal.
Any directions where to start? How would you make continuous buffer?

They called it ring buffer. Unlikely you can store 6 sec. of decent quality audio - not enough memory. What you have?

Not even 6s?! Maybe using some sort of "memory shield". That can not be so high datarate that SD card could not also be an option, right?

There is a topic, sampling analog at 100 ksps , on this forum, you may try to search. Data is stored to SD, AFAIR.