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

Ensure callback is called whenever a value is discarded #5

Closed
wants to merge 3 commits into from
Closed

Ensure callback is called whenever a value is discarded #5

wants to merge 3 commits into from

Conversation

btimby
Copy link
Contributor

@btimby btimby commented Apr 22, 2013

In my use-case, the value being stored in cache cannot be garbage collected. My callback is responsible for cleaning it up. There are certain conditions that the object reference is removed from cache, but the callback is never called.

This pull requests addresses that by adding some additional calls to callback. The unit tests still pass. I supplied new unit tests for the new functionality.

@jlhutch
Copy link
Owner

jlhutch commented Apr 23, 2013

Thanks for the pull request. I'm not going to merge it however. The current
interface is for the callback to be called only when a key/value pair is
pushed out by other keys. Some code relies on this interface. For example,
your changes play havoc with the logic in WriteBackCacheManager,
essentially reducing its behavior to write-through cache semantics.

I'm not saying it is a bad idea though. I wrote Pylru to be simple and easy
to modify, so I hope you will use it however you see fit.

On Mon, Apr 22, 2013 at 4:20 PM, Ben Timby notifications@github.com wrote:

In my use-case, the value being stored in cache cannot be garbage
collected. My callback is responsible for cleaning it up. There are certain
conditions that the object reference is removed from cache, but the
callback is never called.

This pull requests addresses that by adding some additional calls to
callback. The unit tests still pass. I supplied new unit tests for the new

functionality.

You can merge this Pull Request by running

git pull https://github.com/btimby/pylru callback

Or view, comment on, or merge it at:

#5
Commit Summary

  • Always call the callback when an item is removed.
  • Call the callback when replacing an existing key with a new value.
  • Unit test to test callback functionality.

File Changes

Patch Links:

Jay Hutchinson

@jlhutch jlhutch closed this Apr 23, 2013
@btimby btimby deleted the callback branch April 24, 2013 13:43
@btimby
Copy link
Contributor Author

btimby commented Apr 24, 2013

Understood. I must have read more into the callback function than is actually there. I think subclassing will solve my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants