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

return value of proxy functions #136

Open
cutewalker opened this issue Feb 24, 2016 · 0 comments
Open

return value of proxy functions #136

cutewalker opened this issue Feb 24, 2016 · 0 comments

Comments

@cutewalker
Copy link

for the proxy functions as following

  • Cache.set
  • Cache.add
  • Cache.delete
  • Cache.delete_many
  • Cache.clear
  • Cache.set_many

the return value is always None.
but we sometimes really need the return value of the internal cache object 's operations.
for example, we can use memcache.add as a distributed lock to guarantee atomic operations:

if memcache.add(key, value):
    do_something_exclusively
else:
    # someone else is doing the same thing
    pass

but without the retuen value, we have to use cache.cache.add.

So, would you consider this and change the proxy functions like this:

     def add(self, *args, **kwargs):
         "Proxy function for internal cache object."
-        self.cache.add(*args, **kwargs)
+        return self.cache.add(*args, **kwargs)

or is there some other reason to keep discarding interal operation's return value ?

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

No branches or pull requests

1 participant