Search code examples
phpredispredis

Predis. How to set Cyrillic key?


I trying to execute next command.

Redis::hincrby('sentiment_combined:positive', 'рыжий кот', 1);

This command works perfectly for latin keys, for example 'orange cat'. But with 'рыжий кот' I have next error:

[Predis\Response\ServerException]         
ERR Protocol error: expected '$', got '�'  <

I has added log into Predis Predis\Connection\StreamConnection::write()

print_r($buffer);echo "---$written---\n";

And I observe output in console:

*2
$6
SELECT
$1
0
---23---
*4
$7
HINCRBY
$27
sentiment_combined:positive
$9
рыжий кот
$1
1
---81---

Redis supporting any keys. How to overcome this limitation in Predis?


Solution

  • Problem solved here: https://github.com/nrk/predis/issues/328

    Reason in mbstring.func_overload = 6 in php.ini. Must be mbstring.func_overload = 0.