allegro / allegro/bigcache

Why does cacheShard.set call onEvict?

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

Beschreibung

I have two problems with this:
1. It is **redundant**, the oldest entry will be removed anyway if space is needed for the new entry
2. It can cause **set** to invoke **onRemoveWithReason** with both "Expired" and "NoSpace" This is troublesome because **cleanUp** also invokes **onRemoveWithReason** with "Expired," making it impossible to differentiate between when **set** invokes **onRemoveWithReason** and when **cleanUp** invokes **onRemoveWithReason**

Proposed solution: Only remove the oldest entry in **set** with reason "NoSpace"

The point in all this is that each function/goroutine which might remove something from the cache should have its own **distinct** reason for doing so, thus preventing overlap and therefore allowing a developer to know **precisely** why an entry was removed.,

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.