Skip to content

Instantly share code, notes, and snippets.

@iKlsR
Forked from wuliupo/redis.php
Created June 16, 2019 11:20
Show Gist options
  • Save iKlsR/c6dff55e93ec922020aa839c19fd0708 to your computer and use it in GitHub Desktop.
Save iKlsR/c6dff55e93ec922020aa839c19fd0708 to your computer and use it in GitHub Desktop.
php-redis-on-windows
<?php
$host = 'test.kvstore.aliyuncs.com';
$port = 6379;
$user = 'username';
$pwd = 'password1234';
$key = 'the_stored_key';
$redis = new Redis();
if ($redis->connect($host, $port) == false) {
die($redis->getLastError());
}
if ($redis->auth($pwd) == false) {
die($redis->getLastError());
}
if ($redis->set($key, 'this is a test string. '.rand(100, 10000)) == false) {
die($redis->getLastError());
}
$value = $redis->get($key);
echo '<hr/>get data from Redis: '.$key.' = '.$value;
?>
@iKlsR
Copy link
Author

iKlsR commented Jun 16, 2019

Environment setup

* check your platform (like: Windows, Thread safe, 32-bit) PHP 5.6 Thread Safe (TS) x86

* php_redis.dll
  
  * http://pecl.php.net/package/redis/2.2.7/windows
  * http://windows.php.net/downloads/pecl/releases/redis/2.2.7/php_redis-2.2.7-5.6-ts-vc11-x86.zip

* php_igbinary.dll
  
  * http://pecl.php.net/package/igbinary/1.1.1/windows
  * http://windows.php.net/downloads/pecl/releases/igbinary/1.1.1/php_igbinary-1.1.1-5.6-ts-vc11-x86.zip

* modify php.ini
[redis]
extension=php_igbinary.dll
extension=php_redis.dll

for PHP 7, http://pecl.php.net/package/redis/3.1.0/windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment