Asf_Cache_Adapter_Redis Asf_Cache_Adapter_Redis::__construct(array $options)

(Asf >= 2.2.2)

Connect Redis Server

Redis Connect Options:

Examples

Example #1

<?php
use Asf\Cache\Adapter\Redis;

$options = array('host' => '1.1.1.1', 'port' => '6379', 'password' => 'password', 'persistent' => '0', 'timeout' => 1, 'select' => 0);
$redis = new Redis($options);

print_r($redis);
print_r($redis->getConnectInfo());
print_r($redis->getHandler());

$key = 'asf_test';

var_dump($redis->has($key));
var_dump($redis->get($key));

echo '------------------------set/has/get', PHP_EOL;
var_dump($redis->set($key, 1));
var_dump($redis->has($key));
var_dump($redis->get($key));

echo '------------------------__call: setTimeout/expire/strlen', PHP_EOL;
var_dump($redis->setTimeout($key, 86400));
var_dump($redis->expire($key, 86400));
var_dump($redis->strlen($key));

echo '------------------------incr/decr', PHP_EOL;
var_dump($redis->incr($key));
var_dump($redis->decr($key));

var_dump($redis->incr($key, 10));
var_dump($redis->decr($key, 5));

echo '------------------------get', PHP_EOL;
var_dump($redis->get($key));

echo '------------------------del', PHP_EOL;
var_dump($redis->del($key));

echo '------------------------flushDB', PHP_EOL;
var_dump($redis->clear());

echo '------------------------close', PHP_EOL;
var_dump($redis->close());