-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
redis hashes as php array #39
Comments
Good idea. @cebe would it break BC? |
And not only hashes - zrange, zrevrange .etc with options WITHSCORES too $redis->executeCommand('ZREVRANGE',['myzset', 0, 2, 'WITHSCORES']);
#return ['value1',5,'value2',4] best expected ['value1'=>5, 'value2'=>4] |
Not completely clear but it may be implemented as separate method |
this will break existing magic methods. |
|
Hi, all~ /**
* post process for redis hgetall, rebind the key-value relation
* @param array $arr
* @param array $decodeFileds the filed names need json_decode
* @return NULL|[]
* @author xieyh
*/
public static function postRedisHgetall($arr, $decodeFileds = null) {
if(empty($arr)) return null;
$cnt = count($arr);
$data = [];
for($i = 0; $i < $cnt; $i += 2){
$filed = $arr[$i];
$value = $arr[$i+1];
if($decodeFileds && in_array($filed, $decodeFileds)){
$value = json_decode($value, TRUE);
}
$data[$filed] = $value;
}
return $data;
} |
The feature of returning associative array is useful. |
I propose to explicitly define next methods in \yii\redis\Connection
To work with redis hashes as php associative arrays
e.g.
The text was updated successfully, but these errors were encountered: