allegro / allegro/bigcache

rationale behind `minimumHeaderSize` in `bytes_queue` package

Offen
#284 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
8.2k
Forks
614
Ø Merge
5 T. 12 Std.
Gemergte PRs (30 T.)
1

Beschreibung

To understand the issue take a look at this test:
```Go
func TestBytesQueue(t *testing.T) {
// given
queue := NewBytesQueue(10, 10, true)

// when
queue.Push([]byte("hello"))
queue.Push([]byte("m"))
queue.Pop()
_, err := queue.Push([]byte("o"))
if err != nil {
// test will fail here
// queueError{"Full queue. Maximum size limit reached."}
t.Fatal("Queue should have pushed `o`")
}

// then
// expected result
assertEqual(t, 2, queue.Len())
}
```
Clearly, the buffer has enough space to add `[]byte("o")`. Specifically, `canInsertBeforeHead` method should return true, but `minimumHeaderSize` prevents this to happen.
I am curious to know about the rationale behind `minimumHeaderSize` because as you saw it prevents testing/using this package intuitively.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.