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

Command 'iNCRBY' is not a registered Redis command error #372

Closed
deepmk opened this issue Aug 18, 2016 · 6 comments
Closed

Command 'iNCRBY' is not a registered Redis command error #372

deepmk opened this issue Aug 18, 2016 · 6 comments

Comments

@deepmk
Copy link

deepmk commented Aug 18, 2016

strtoupper function and different character sets in the problem PREDIS package

sample
setlocale(LC_ALL, 'tr_TR.utf8', 'tr_TR.utf8', 'tr_TR');

used in a project that brings problems

sample
if (isset($this->commands[$commandID = strtoupper($commandID)])) { return $this->commands[$commandID]; }

INCRBY = iNCRBY

I solved the problem by using mb_strtoupper instead strtoupper.

@nrk
Copy link
Contributor

nrk commented Oct 3, 2016

Apparently the Turkish language just decided to make things weird here! Jokes aside, I would've never guessed such an issue when uppercasing strings with plain latin characters but I've just read about it here and well... you learn something new every day 😄 Not sure how to fix this right now but unfortunately mbstring is a non-default extension so we can't really rely on it.

@baskan
Copy link

baskan commented Nov 1, 2016

@widlturk fix is actually just replace ReplaceProfile.php line 85 to:

    $commandID = mb_strtoupper($commandID, 'UTF-8');

@nrk is there a way that we can use our own Profiler implementing ProfileInterface ?

@egurelli
Copy link

So same issue happened to me also when I using Laravel (5.3) Cache. I have investigated the issue and codes both Laravel lib and Predis lib.

Looks like Predis proxy commands to Redis. From Laravel (5.3) documents :

You may interact with Redis by calling various methods on the Redis facade. The Redis facade supports dynamic methods, meaning you may call any Redis command on the facade and the command will be passed directly to Redis.

So my solution on Laravel (probably will be same on other framework platforms or native users) :

use commands like in Redis documents with "case sensitive"

Redis::incrby
Result : Command 'iNCRBY' is not a registered Redis command.

Redis::INCRBY
Result : Success

Note : Packages/Vendors using "lowercase" Redis commands and that cause same problem : Probably extending Class and redefine functions/methods may solve the issue.

@nrk
Copy link
Contributor

nrk commented Nov 11, 2016

@baskan yes with Predis v1.x you can implement Predis\Profile\ProfileInterface, extend Predis\Profile\RedisProfile or extend one of its subclasses and then pass the instance of this class to the profile client option when creating a new client:

$profile = new \My\New\RedisProfile();
$client = new \Predis\Client($parameters, ['profile' => $profile]);

Please note that in this specific case you are still going to have problems with other parts of the library where strtoupper() is being used for commands, such as Predis\Command\Processor\KeyPrefixProcessor, Predis\Cluster\ClusterStrategy and Predis\Replication\ReplicationStrategy.

@canturkm
Copy link

If you don't want to change code,

export LANG=en_US.utf8

shell command also solves the problem.

@MichaelMenge
Copy link

how about setting the locale to "C" or "en_US.utf8" and restoring it to the original before returning to the caller

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

No branches or pull requests

7 participants