Database: Redis
install the redis extension phpredis
configuration in configs.php
return [
'components' => [
'redis' => [
'product' => [
'host' => 'localhost',
'pconnect' => true,
],
'default' => [
'host' => 'localhost',
'pconnect' => true,
],
],
// ...
],
// ...
];
$app->get('/product/:id', function($id) {
$this->redis->product->incr('view:'.$id);
});
$app->get('/', function(){
$this->redis->counter->incr(); // same as $this->redis->default->incr('cunter');
});
$this->redis->foo->bar = 'val'; // same as $this->redis->hset('foo', 'bar', 'val');
$this->redis->foo->hget('bar'); // same as $this->redis->hget('foo', 'bar');