summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-27 22:32:29 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-27 22:32:29 -0600
commitfc881047d0ed06a6cc26b195e6a15e65cb558178 (patch)
tree81d5ca1980259a8ad008ab9b741056fcf083b4c5
parenta22ef19c05736933f6380fe5744bc67d06d5566b (diff)
touch up commentslukeshu/node-cache
-rw-r--r--lib/caching/arcache.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/caching/arcache.go b/lib/caching/arcache.go
index 892cf8a..5b7394c 100644
--- a/lib/caching/arcache.go
+++ b/lib/caching/arcache.go
@@ -400,9 +400,10 @@ func (c *arCache[K, V]) dblReplace() *LinkedListEntry[arcLiveEntry[K, V]] {
// c.recentLive, c.frequentPinned, c.frequentLive, or c.unusedLive),
// and is ready to be stored into a list by the caller.
//
-// If an eviction is performed, the `ghostEntry` argument is where the
-// eviction should be recorded to. `ghostEntry` is still present in
-// its old list, in case an eviction is not performed.
+// If an eviction is performed, `ghostEntry` is a pointer to the entry
+// object that is used as a record of the eviction. `ghostEntry`
+// should still be present in its old list, in case an eviction is not
+// performed and the `ghostEntry` object is not modified.
//
// The `arbitrary` argument is arbitrary, see the quote about it
// below.
@@ -410,8 +411,10 @@ func (c *arCache[K, V]) arcReplace(ghostEntry *LinkedListEntry[arcGhostEntry[K]]
c.waitForAvail()
// If the cache isn't full, no need to do an eviction. (This
- // is a nescessary enhancement over standard ARC in order to
- // support "delete".)
+ // check is a nescessary enhancement over standard ARC in
+ // order to support "delete"; because without "delete",
+ // arcReplace wouldn't ever be called when the cache isn't
+ // full.)
if entry := c.unusedLive.Oldest; entry != nil {
c.unusedLive.Delete(entry)
return entry