|
21 | 21 | import java.util.function.Function; |
22 | 22 |
|
23 | 23 | /** |
24 | | - * Generic buffer data structure for storing events by key with size-based eviction. |
| 24 | + * Thread-safe buffer that stores events by key with size-based eviction. |
25 | 25 | * |
26 | | - * <p>This buffer maintains separate event queues for each key, with configurable size limits |
27 | | - * to prevent memory exhaustion. When buffers exceed their size limit, older events are |
28 | | - * automatically evicted to make room for newer ones. |
| 26 | + * <p>Maintains separate queues per key. When buffer size exceeds maxBytes, |
| 27 | + * oldest events are evicted FIFO. Events larger than maxBytes are rejected. |
29 | 28 | * |
30 | | - * <h3>Key Features:</h3> |
31 | | - * <ul> |
32 | | - * <li><strong>Per-key buffering:</strong> Each key maintains its own independent buffer</li> |
33 | | - * <li><strong>Size-based eviction:</strong> Oldest events are removed when buffer size exceeds limit</li> |
34 | | - * <li><strong>Overflow protection:</strong> Events larger than buffer size are rejected entirely</li> |
35 | | - * <li><strong>Thread-safe:</strong> Supports concurrent access across different keys</li> |
36 | | - * <li><strong>Overflow tracking:</strong> Logs warnings when events are evicted or rejected</li> |
37 | | - * </ul> |
38 | | - * |
39 | | - * <h3>Eviction Behavior:</h3> |
40 | | - * <ul> |
41 | | - * <li><strong>Buffer overflow:</strong> When adding an event would exceed maxBytes, oldest events are evicted first</li> |
42 | | - * <li><strong>Large events:</strong> Events larger than maxBytes are rejected without evicting existing events</li> |
43 | | - * <li><strong>FIFO eviction:</strong> Events are removed in first-in-first-out order during overflow</li> |
44 | | - * <li><strong>Overflow warnings:</strong> Automatic logging when events are evicted or rejected</li> |
45 | | - * </ul> |
46 | | - * |
47 | | - * <h3>Thread Safety:</h3> |
48 | | - * <p>This class is thread-safe for concurrent operations. Different keys can be accessed |
49 | | - * simultaneously, and operations on the same key are synchronized to prevent data corruption. |
50 | | - * |
51 | | - * @param <K> the type of key used for buffering (e.g., String for trace IDs) |
52 | | - * @param <T> the type of events to buffer (must be compatible with the size calculator) |
| 29 | + * @param <K> key type for buffering |
| 30 | + * @param <T> event type to buffer |
53 | 31 | */ |
54 | 32 | public class KeyBuffer<K, T> { |
55 | 33 |
|
|
0 commit comments