add GetDropped documentation
This commit is contained in:
parent
1a257a89d6
commit
d9aec58960
1 changed files with 10 additions and 0 deletions
10
readme.md
10
readme.md
|
@ -13,7 +13,9 @@ Unless otherwise stated, all methods are thread-safe.
|
||||||
|
|
||||||
First, download the project:
|
First, download the project:
|
||||||
|
|
||||||
|
```go
|
||||||
go get github.com/karlseguin/ccache
|
go get github.com/karlseguin/ccache
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
Next, import and create a `Cache` instance:
|
Next, import and create a `Cache` instance:
|
||||||
|
@ -109,6 +111,14 @@ cache.Replace("user:4", user)
|
||||||
|
|
||||||
`Replace` returns true if the item existed (and thus was replaced). In the case where the key was not in the cache, the value *is not* inserted and false is returned.
|
`Replace` returns true if the item existed (and thus was replaced). In the case where the key was not in the cache, the value *is not* inserted and false is returned.
|
||||||
|
|
||||||
|
### GetDropped
|
||||||
|
You can get the number of keys evicted due to memory pressure by calling `GetDropped`:
|
||||||
|
|
||||||
|
```go
|
||||||
|
dropped := cache.GetDropped()
|
||||||
|
```
|
||||||
|
The counter is reset on every call. If the cache's gc is running, `GetDropped` waits for it to finish; it's meant ot be called asynchronously for statistics /monitoring purposes.
|
||||||
|
|
||||||
### Stop
|
### Stop
|
||||||
The cache's background worker can be stopped by calling `Stop`. Once `Stop` is called
|
The cache's background worker can be stopped by calling `Stop`. Once `Stop` is called
|
||||||
the cache should not be used (calls are likely to panic). Stop must be called in order to allow the garbage collector to reap the cache.
|
the cache should not be used (calls are likely to panic). Stop must be called in order to allow the garbage collector to reap the cache.
|
||||||
|
|
Loading…
Reference in a new issue