_unserialize 命令/方法/函数


A utility method to unserialize data with whatever serializer is set up. If there is no serializer set, the value will be returned unchanged. If there is a serializer set up, and the data passed in is malformed, an exception will be thrown. This can be useful if phpredis is serializing values, and you return something from redis in a LUA script that is serialized.



value string. The value to be unserialized


$redis->setOpt(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);

$redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return Array(1,2,3)