|
|
@ -20,17 +20,16 @@ one) to recover from downtime quickly. (See the docs for `NewFrom()` for caveats
|
|
|
|
### Usage
|
|
|
|
### Usage
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
```go
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"github.com/patrickmn/go-cache"
|
|
|
|
"github.com/patrickmn/go-cache"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
// Create a cache with a default expiration time of 5 minutes, and which
|
|
|
|
// Create a cache with a default expiration time of 5 minutes, and which
|
|
|
|
// purges expired items every 30 seconds
|
|
|
|
// purges expired items every 10 minutes
|
|
|
|
c := cache.New(5*time.Minute, 30*time.Second)
|
|
|
|
c := cache.New(5*time.Minute, 10*time.Minute)
|
|
|
|
|
|
|
|
|
|
|
|
// Set the value of the key "foo" to "bar", with the default expiration time
|
|
|
|
// Set the value of the key "foo" to "bar", with the default expiration time
|
|
|
|
c.Set("foo", "bar", cache.DefaultExpiration)
|
|
|
|
c.Set("foo", "bar", cache.DefaultExpiration)
|
|
|
@ -99,7 +98,7 @@ one) to recover from downtime quickly. (See the docs for `NewFrom()` for caveats
|
|
|
|
// 1
|
|
|
|
// 1
|
|
|
|
// 2
|
|
|
|
// 2
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Reference
|
|
|
|
### Reference
|
|
|
|