Skip to content

fix ignored version in first get_or_set fetch #123

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AlexRiina
Copy link

Fixes #122

get_or_set had been ignoring the key's version in it's attempt to fetch the key from cache initially. When using a versioned key, get_or_set therefore always misses the cache, runs the expensive function, and then updates the right key in the cache.

I'm having some getting the tests to pass, but here is some example code to show the issue.

cache.set('x', 'yay', version=2)
cache.set('x', 'boo')

cache.get_or_set('x', lambda: 'x', version=2)
> 'boo'

cache.get('x')
> 'yay'

Alex Riina and others added 2 commits October 5, 2016 17:50
get_or_set had been ignoring the key's version in it's attempt to fetch
the key from cache initially. When using a versioned key, get_or_set
therefore always misses the cache, runs the expensive function, and then
updates the right key in the cache.
@AlexRiina
Copy link
Author

Based on the failures, I might be going about this the wrong way. An alternative could be

- self.get(key)
+ value = client.get(key)
+ value = self.get_value(value)

which looks like it will keep the client the same.

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.

1 participant