Skip to content

Commit c0806d2

Browse files
author
chenyijun.266846
committed
fix(setnx2): promotables
1 parent d59160b commit c0806d2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cache.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ func (c *Cache[T]) Setnx(key string, value T, duration time.Duration) {
126126

127127
// Setnx2 set the value in the cache for the specified duration if not exists
128128
func (c *Cache[T]) Setnx2(key string, f func() T, duration time.Duration) *Item[T] {
129-
return c.bucket(key).setnx2(key, f, duration, false)
129+
item := c.bucket(key).setnx2(key, f, duration, false)
130+
c.promotables <- item
131+
return item
130132
}
131133

132134
// Replace the value if it exists, does not set if it doesn't.

0 commit comments

Comments
 (0)