Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Ring Buffer

A fixed-capacity FIFO that overwrites its oldest entry, demoing the p/moul/x/daily/ringbuffer library.

Capacity 4, pushing 6 entries:

push evicted contents (oldest → newest)
alpha alpha
bravo alpha bravo
charlie alpha bravo charlie
delta alpha bravo charlie delta
echo alpha bravo charlie delta echo
foxtrot bravo charlie delta echo foxtrot

The buffer never grows: once full, each push costs the oldest entry. On chain that bound is the point — an unbounded queue is an unbounded storage bill.