Skip to content

Commit d9aec58

Browse files
committed
add GetDropped documentation
1 parent 1a257a8 commit d9aec58

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ Unless otherwise stated, all methods are thread-safe.
1313

1414
First, download the project:
1515

16+
```go
1617
go get github.com/karlseguin/ccache
18+
```
1719

1820
## Configuration
1921
Next, import and create a `Cache` instance:
@@ -109,6 +111,14 @@ cache.Replace("user:4", user)
109111

110112
`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.
111113

114+
### GetDropped
115+
You can get the number of keys evicted due to memory pressure by calling `GetDropped`:
116+
117+
```go
118+
dropped := cache.GetDropped()
119+
```
120+
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.
121+
112122
### Stop
113123
The cache's background worker can be stopped by calling `Stop`. Once `Stop` is called
114124
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.

0 commit comments

Comments
 (0)