Download redis server for Windows.
# List files
dir redis
libhiredis.dll
redis-benchmark.exe
redis-check-aof.exe
redis-check-dump.exe
redis-cli.exe
redis-server.exe
redis.conf
# Run redis server
redis-server.exe redis.conf
Download PHP extension to connect with Redis: php_redis.dll
Code PHP:
<?php
$time_start = microtime(true);
##############################
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
/*
for ($i = 0 ; $i < 1000000; $i++) {
$key = md5('hhh' . $i);
$value = 'I am mct: ' . microtime() . '_' . uniqid();
$redis->set($key, $value);
}
$redis->save();
*/
$keys = array(md5('hhh99999'), md5('hhh99996'));
var_dump($redis->mget($keys));
var_dump($redis->get(md5('hhh99992')));
$redis->close();
##############################
$time_end = microtime(true);
$time = $time_end - $time_start;
$secs = $time;
echo 'Done! ' . sprintf('%02u:%02u:%02u', $secs / 3600, $secs % 3600 / 60, $secs % 60) . ' seconds';
Title:
PHP connect to Redis on Windows
Description:
Download redis server for Windows. # List files dir redis libhiredis.dll redis-benchmark.exe redis-check-aof.exe redis-check-dump.exe...
...
Rating:
4