Skip to content

Commit 8480cb3

Browse files
authored
Add a notice for the cache duration precision issue. (#119)
see #118
1 parent 04ae1f1 commit 8480cb3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ fmt.Println("entry count ", cache.EntryCount())
5656
* Memory is preallocated.
5757
* If you allocate large amount of memory, you may need to set `debug.SetGCPercent()`
5858
to a much lower percentage to get a normal GC frequency.
59+
* If you set a key to be expired in X seconds, e.g. using `cache.Set(key, val, X)`,
60+
the effective cache duration will be within this range: `(X-1, X] seconds`.
61+
This is because that sub-second time at the moment will be ignored when calculating the
62+
the expiration: for example, if the current time is 8:15::01.800 (800 milliseconds passed
63+
since 8:15::01), the actual duration will be `X-800ms`.
5964

6065
## How it is done
6166

0 commit comments

Comments
 (0)