Skip to content

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