Home >Backend Development >PHP Tutorial >XAMPP configuration redis module under win7

XAMPP configuration redis module under win7

WBOY
WBOYOriginal
2016-08-08 09:31:411180browse

1. Use phpinfo() to check the PHP version

My computer shows: php 5.6 32-bit.

Second, download the corresponding version of the php-redis module,

Put the downloaded php_redis.dll and php_igbinary.dll into xampp/php/ext,

modify php.ini, and add:

extension=php_igbinary.dll
extension=php_redis.dll

Restart XAMPP, At this time, you can see in phpinfo() that the redis module is loaded normally.

I encountered a lot of problems during installation. My summary is as follows:

1. You need to download the phpredis module corresponding to the php version;

2. Pay attention to whether it is 32-bit or 64-bit. This depends on the Architecture output by phpinfo(), not the number of operating systems.

3. When downloading, -ts- is thread-safe, and -nts- is non-thread-safe.

4. You can download it from here

3. Usage examples

$redis = new Redis();  
$redis->connect("localhost","6379");
$redis->set("say","Hello World");  
echo $redis->get("say");     //输出Hello World  ,程序运行成功。
   

4. Common operations

//设置key
$redis->set('val1','abc');
echo $redis->get('val1').'<br>'; 
//删除key
$redis->del('val1');// 返回 TRUE(1)
var_dump($redis->get('val')); //返回 bool(false)
//key是否存在
if(!$redis->exists('key1')) //不存在
var_dump($redis->del('key1')); //返回 int(0)
//mset集合设置
$array_mset=array('first_key'=>'first_val',
          'second_key'=>'second_val',
          'third_key'=>'third_val');
$redis->mset($array_mset); 
$array_mget=array('first_key','second_key','third_key');
var_dump($redis->mget($array_mget)); //返回array

$redis->del($array_mget); //使用array同时删除多个key
var_dump($redis->mget($array_mget)); //返回 array(3) { [0]=> bool(false) [1]=> bool(false) [2]=> bool(false) }

The above introduces the XAMPP configuration redis module under win7, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn