8000 Variable number of arguments to methods · Issue #14 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content

Variable number of arguments to methods #14

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

Closed
chriso opened this issue Apr 29, 2011 · 4 comments
Closed

Variable number of arguments to methods #14

chriso opened this issue Apr 29, 2011 · 4 comments

Comments

@chriso
Copy link
chriso commented Apr 29, 2011

Some methods such as sUnion() take a variable number of arguments. It would be awesome to have a variant of each method which takes an array of arguments - i.e. something like sprintf vs. vsprintf.

Currently we have to call_user_func_array or do a switch on count($args) if we don't know the number of arguments in advance.

@nicolasff
Copy link
Member

Hi Chris,

Some of the methods that take a variable number of arguments already do take an array if provided.
This is the case for the following methods:

  • DEL
  • WATCH
  • BLPOP/BRPOP
  • SINTER/SINTERSTORE
  • SUNION/SUNIONSTORE
  • SDIFF/SDIFFSTORE

It adds a certain complexity to the code, so I won't add any more if there's no support for variadic commands in Redis. I'm aware of some recent changes in methods such as LPUSH that can now take a number of arguments, but I'm not sure that all of these can be made compatible with an array equivalent.

I'm leaving this ticket open until proper support for those new changes have been added.

@chriso
Copy link
Author
chriso commented May 1, 2011

Ah k, thanks.

@chriso chriso closed this as completed May 1, 2011
@chriso chriso reopened this May 1, 2011
@colinmollenhour
Copy link

Do sRem and sAdd take an array? Is it less efficient to use call_user_func_array? I ask because my Zend_Cache backend which uses phpredis seems to get considerably slower at some point when there is a large number of keys and I'm suspecting that calling these methods with call_user_func_array and a huge number of parameters could be the issue. -Thanks!

@nicolasff
Copy link
Member

@colinmollenhour you can use an array, or a variable number of arguments, I'm not sure it would make that much of a difference. Please try the latest version though, I pushed a fix a few days ago that should speed up these commands when dealing with very large numbers of keys.

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

3 participants
0