facebook twitter hatena line email

Php/fuelphp/memcached

提供: 初心者エンジニアの簡易メモ
2015年5月20日 (水) 03:08時点における127.0.0.1 (トーク)による版 (ページの作成:「==memcachedを使う== *fuel/app/config/cache.php <?php return array( 'driver' => 'memcached', 'expiration' => null, 'memcached' => array( 'cache_id' => 'fu...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

memcachedを使う

  • fuel/app/config/cache.php
<?php
return array(
 'driver' => 'memcached',
 'expiration' => null,
 'memcached'  => array(
   'cache_id'  => 'fuel', // アプリのunique_idなどをいれておく。
   'servers'   => array(
     'default' => array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100)
   ),
 ),
);
  • fuel/app/controller/sample/php
try {
    $test = Cache::get('test');
} catch (\CacheNotFoundException $e) {
    $test = 1;
    Cache::set('test', $test);
}

個別有効時間指定

Cache::set('test', $test, 3600); // 1h