Skip to content

Commit f702a0f

Browse files
author
Чагин Максим
committed
fix markdown
1 parent 056c9f3 commit f702a0f

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
Инициализировать кеш
1919

20-
// Создаем кеш с временем жизни по-умолчанию равным 5 минут и удалением просроченного кеша каждые 10 минут
20+
// Создаем кеш с временем жизни по-умолчанию равным 5 минут и удалением просроченного кеша каждые 10 минут
2121
cache := memorycache.New(5 * time.Minute, 10 * time.Minute)
2222

2323

@@ -27,4 +27,4 @@
2727
cache.Set("myKey", "My value", 5 * time.Minute)
2828

2929
// Получить кеш с ключем "myKey"
30-
i := cache.Get("myKey")
30+
i := cache.Get("myKey")

memorycache.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ func (c *Cache) Set(key string, value interface{}, duration time.Duration) error
4747

4848
var expiration int64
4949

50+
if duration == 0 {
51+
duration = c.defaultExpiration
52+
}
53+
5054
if duration > 0 {
5155
expiration = time.Now().Add(duration).UnixNano()
5256
}

memorycache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const (
1212
)
1313

1414
// AppCache init new cache
15-
var AppCache = New(10*time.Minute, 1*time.Minute)
15+
var AppCache = New(10*time.Minute, 1*time.Hour)
1616

1717
// AppCache init new cache
1818
var AppCacheGC = New(10*time.Minute, 1*time.Second)

0 commit comments

Comments
 (0)