- <?php
- return array(
- // default storage driver
- 'driver' => 'redis',
- // default expiration (null = no expiration)
- 'expiration' => null,
- // specific configuration settings for the redis driver
- 'redis' => array(
- 'database' => 'default', // name of the redis database to use (as configured in config/db.php)
- ),
- );
- <?php
- /**
- * The development database settings. These get merged with the global settings.
- */
- return array(
- 'default' => array(
- 'connection' => array(
- 'dsn' => 'mysql:host=localhost;dbname=fuel_dev',
- 'username' => 'root',
- 'password' => 'root',
- ),
- ),
- // --- 以下を追記
- 'redis' => array(
- 'default' => array(
- 'hostname' => '127.0.0.1',
- 'port' => 6379,
- 'timeout' => null,
- 'database' => 0,
- ),
- ),
- );
- <?php
- class Controller_Test extends Controller
- {
- public function action_index()
- {
- $counter = 0;
- try {
- $counter = Cache::get('counter');
- } catch (\CacheNotFoundException $e) {
- // 初回、キーが存在しない場合はエラーになる
- }
- echo $counter;
- Cache::set('counter', $counter + 1);
- }
- }
Author:symfo
blog形式だと探しにくいので、まとめサイト作成中です。
Symfoware まとめ