Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make expiration optional. #45

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ For API docs and examples, see http://godoc.org/github.com/mailgun/groupcache
cluster eventually becomes consistent again.

* Support for expired values. `SetBytes()`, `SetProto()` and `SetString()` now
accept an optional `time.Time{}` which represents a time in the future when the
value will expire. Expiration is handled by the LRU Cache when a `Get()` on a
key is requested. This means no network coordination of expired values is needed.
However this does require that time on all nodes in the cluster is synchronized
for consistent expiration of values.
accept an optional `time.Time` which represents a time in the future when the
value will expire. If you don't want expiration, pass the zero value for
`time.Time` (for instance, `time.Time{}`). Expiration is handled by the LRU Cache
when a `Get()` on a key is requested. This means no network coordination of
expired values is needed. However this does require that time on all nodes in the
cluster is synchronized for consistent expiration of values.

* Now always populating the hotcache. A more complex algorithm is unnecessary
when the LRU cache will ensure the most used values remain in the cache. The
Expand Down
4 changes: 4 additions & 0 deletions sinks.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ var _ Sink = &byteViewSink{}
//
// Implementation of Getter must call exactly one of the Set methods
// on success.
//
// `e` sets an optional time in the future when the value will expire.
// If you don't want expiration, pass the zero value for
// `time.Time` (for instance, `time.Time{}`).
type Sink interface {
// SetString sets the value to s.
SetString(s string, e time.Time) error
Expand Down