Dmitriy Gnatenko 1b9d3a6ed8 Add LRU memory cache | 6 meses atrás | |
---|---|---|
.. | ||
cache.go | 6 meses atrás | |
cache_config.go | 6 meses atrás | |
readme.md | 6 meses atrás |
cache := NewCache(
NewConfig(
memoryCache.WithCleanupInterval(30*time.Minute),
memoryCache.WithExpiration(time.Hour),
),
)
cache.Set("1", "value 1", nil)
exp := 12*time.Hour
cache.Set("2", "value 2", &exp)
val1, found1 := cache.Get("1") // "value 1", true
val3, found3 := cache.Get("3") // nil, false