Hello I'm using redis as a game developer and I'm having a tricky issue that I've debugged extensively. Basically, I have a variable on my game client that gets set with a key from redis using phpredis.
On my game client:
my_user = input_from_server;
Such that my_user now holds the string value "piece" which I will use to set up a new redis list.
So to describe my problem, when I push to the key "piece" from a separate game client I can pop "piece" from the redis-cli, furthermore I can pop from the "other" game client when I statically type out "piece", but when I use the variable my_user it doesn't work.
I am sure that the my_user variable is holding the string value "piece".
To sum it up more clearly perhaps, on my server I have this:
<?php
//melon game pop
//connect to redis db
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
//receive the data as json
$data = json_decode(file_get_contents('php://input'), true);
//parse my data in to separate variables
if ($data != null) {
$key = $data['key'];
$value = $data['value'];
}
$my_echo = $redis->rpop($key);
print $my_echo;
?>
Which works only if the data coming in hasn't been set from redis. I'm only using lists currently in my redis database, so theres no confusion on which key type I'm getting.
I feel like I'm eating crazy pills, because it all works fine until I start using the dynamically set variables.
Ok, so I ran keys on my database and found this:
129) "amoral" 130) "a\xe4\xbd\xa0" 131) "afpfqp" 132) "a\xe4\xbd\xa0\xe6\x88\x91\xe5\xa5\xb9" 133) "a\xe9\xab\x98\xe8\x80\x83\xe5\x93\xa6\xe5\x9c\xa8\xe6\x88\x91\xe4\xbb\xac\xe5\x93\xa6\xe5\x85\x9c\xef\xbc\x8ctu" 134) "httpass1"
The keys with the backslashes aren't ones I was expecting. Is this some kind of encoding? And is there a way to workaround it?