Reference website
Phpredis Extension: Https://github.com/phpredis/phpredis#pconnect-popen
Command reference: Http://doc.redisfans.com Redis
Summary of Redis operation exceptions
1. The obtained key exists, using the wrong method, such as: string with hashes method, return false.
2. Get the nonexistent key false.
3. Set the nonexistent key, write the value, return 1, and return 0 if there is a replacement. With a function of type hsetnx, there is a value that returns false without setting a value, or true setting.
Redis Batch Testing
Batch
$redis = new \redis ();
$redis->pconnect (' 127.0.0.1 ');
$redis->auth (' 111111 ');
$ts = Microtime (true);
Var_dump ($ts);
$redis->multi ();
for ($i =0; $i < $i + +) {
$redis->set (' Key1 ', ' val1 ');
$redis->get (' Key1 ');
$redis->del (' Key1 ');
}
$redis->exec ();
$DF = Microtime (True)-$ts;
Var_dump ($DF);
Var_dump ($ret);
Die
Single
$redis = new \think\cache\driver\redis ();
$ts = Microtime (true);
Var_dump ($ts);
for ($i =0; $i < $i + +) {
$redis->set (' Key1 ', ' val1 ');
$redis->get (' Key1 ');
$redis->del (' Key1 ');
}
$DF = Microtime (True)-$ts;
Var_dump ($DF);
Die
Results Batch: Float (1.11732006073) Single: float (1.2670619487762) can be seen in the Phpredis expansion using the batch and the individual and not too much time on the
Difference and http://my.oschina.net/u/2273085/blog/419920, this netizen conclusion difference is very big, perhaps is php own problem, unknown.
Redis Operations General return condition
Redis gets key type error return False
$keyString = ' 13999999999 ';
$keyHash = ' thumbnailserverlist ';
$redisCache = new \think\cache\driver\redis ();
$return = $redisCache->hgetall ($keyString, $value);
Var_dump ($return);
$return = $redisCache->hgetall ($keyHash, $value);
Var_dump ($return);
$return = $redisCache->get ($keyString, $value);
Var_dump ($return);
$return = $redisCache->get ($keyHash, $value);
Var_dump ($return);
Die
Result:bool (FALSE) bool (false) string "9c8d83f5890611e45538a744eb1b036b156790b7533" bool (FALSE) Get type error returns false, Does not exist and is false.
PHP Redis Bulk Operations