Implement ring buffer.