Skip to content

Commit 1d5fe9a

Browse files
committed
fixed some comments for thread safe or not
1 parent 0c7f963 commit 1d5fe9a

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

cache.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func newItem[K comparable, V any](key K, val V, opts ...ItemOption) *Item[K, V]
6262
}
6363
}
6464

65-
// Cache is a cache.
65+
// Cache is a thread safe cache.
6666
type Cache[K comparable, V any] struct {
6767
cache Interface[K, *Item[K, V]]
6868
expirations map[K]chan struct{}
@@ -104,7 +104,9 @@ func AsFIFO[K comparable, V any](opts ...fifo.Option) Option[K, V] {
104104
}
105105
}
106106

107-
// New creates a new Cache.
107+
// New creates a new thread safe Cache.
108+
//
109+
// There are several Cache replacement policies available with you specified any options.
108110
func New[K comparable, V any](opts ...Option[K, V]) *Cache[K, V] {
109111
o := newOptions[K, V]()
110112
for _, optFunc := range opts {

fifo/fifo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func WithCapacity(cap int) Option {
3939
}
4040
}
4141

42-
// NewCache creates a new FIFO cache whose capacity is the default size (128).
42+
// NewCache creates a new non-thread safe FIFO cache whose capacity is the default size (128).
4343
func NewCache[K comparable, V any](opts ...Option) *Cache[K, V] {
4444
o := newOptions()
4545
for _, optFunc := range opts {

lfu/lfu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func WithCapacity(cap int) Option {
3636
}
3737
}
3838

39-
// NewCache creates a new LFU cache whose capacity is the default size (128).
39+
// NewCache creates a new non-thread safe LFU cache whose capacity is the default size (128).
4040
func NewCache[K comparable, V any](opts ...Option) *Cache[K, V] {
4141
o := newOptions()
4242
for _, optFunc := range opts {

lru/lru.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func WithCapacity(cap int) Option {
4040
}
4141
}
4242

43-
// NewCache creates a new LRU cache whose capacity is the default size (128).
43+
// NewCache creates a new non-thread safe LRU cache whose capacity is the default size (128).
4444
func NewCache[K comparable, V any](opts ...Option) *Cache[K, V] {
4545
o := newOptions()
4646
for _, optFunc := range opts {

simple/simple.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type entry[V any] struct {
1515
createdAt time.Time
1616
}
1717

18-
// NewCache creates a new cache.
18+
// NewCache creates a new non-thread safe cache.
1919
func NewCache[K comparable, V any]() *Cache[K, V] {
2020
return &Cache[K, V]{
2121
items: make(map[K]*entry[V], 0),

0 commit comments

Comments
 (0)