Conversation
|
This needs to be reworked against the locking/eviction changes that were just merged. But will be happy to have it after! |
eb1f8f2 to
6b74291
Compare
|
@jefferai ok, done. Please review. |
| } | ||
|
|
||
| // GetAndAdd returns the previous key's value from the cache and adds a new one. | ||
| func (c *Cache) GetAndAdd(key, value interface{}) (previous interface{}, ok, evicted bool) { |
There was a problem hiding this comment.
Given the changes in simplelru, I think you could do the same here -- instead of copying the function entirely, modify Add above to call GetAndAdd and simply throw away the parameters that aren't a part of the call.
There was a problem hiding this comment.
Ah, yes, it's my bad. Refactored, thanks!
jefferai
left a comment
There was a problem hiding this comment.
One comment -- looks good otherwise. Let me know if you agree with that proposal.
6b74291 to
b1235e0
Compare
Yes, you are right, fixed. |
|
@jefferai could you please review and merge if all is ok? |
Hi,
Sometimes it's useful to get value by key and set a new one atomically (like getset in the Redis).