Skip to content

Commit 6cb350a

Browse files
committed
polish
1 parent 380dfef commit 6cb350a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package main
1515
import (
1616
"fmt"
1717
cache "github.com/mkelcik/memory-cache"
18+
"time"
1819
)
1920

2021
type CacheValue struct {
@@ -25,20 +26,20 @@ func main() {
2526
// define type of key and value
2627
// first parameter is pre allocation size
2728
// if second parameter is true, cache is limited to this size, if false the cache can grow beyond this capacity
28-
// third parameter is ttl for cache records in seconds, if is set to 0 the cache items never expire
29+
// third parameter is ttl duration for records, if is set to 0 the cache items never expire
2930
// last parameter is GC interval in seconds, if set to 0, GC will never start automatically
30-
cache := cache.NewCache[int, CacheValue](100, false, 60, 120)
31+
cache := cache.NewCache[int, CacheValue](100, false, 60 * time.Second, 120 * time.Second)
3132

3233
// set data to cache
3334
for i := 1; i <= 100; i++ {
3435
cache.Set(i, CacheValue{Value: 1})
3536
}
36-
37+
3738
// read from cache
3839
itemFromCache, ok := cache.Get(1)
3940
if ok {
4041
fmt.Println("value is:", itemFromCache.Value)
41-
}
42+
}
4243
}
4344
```
4445

0 commit comments

Comments
 (0)