fuelphpでredisを使ってみた

<? php
//インスタンスの生成

//$nameはredis接続先config.phpのredis設定

$redis = Redis_Db::forge($name);

$redis->set('key', 'value');

$a = $redis->get('key');

var_dump($a) . "\n";

$redis->del('key');

$a = $redis->get('key');

var_dump($a) . "\n";

$redis->rpush('key', 'a');

$redis->rpush('key', 'b');

$redis->rpush('key', 'c');

$redis->rpush('key', 'd');

$a = $redis->lrange('key',0,-1);

var_dump($a) . "\n";

$redis->lpush('key', 'a');

$redis->lpush('key', 'b');

$redis->lpush('key', 'c');

$redis->lpush('key', 'd');

$a = $redis->lrange('key',0,-1);

var_dump($a) . "\n";

//有効期間は一時間 

$redis->expireAt('key',time()+3600);

 //削除

 $redis->del('key');

出力結果

string(5) "value" 

NULL 

array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" } 

array(8) { [0]=> string(1) "d" [1]=> string(1) "c" [2]=> string(1) "b" [3]=> string(1) "a" [4]=> string(1) "a" [5]=> string(1) "b" [6]=> string(1) "c" [7]=> string(1) "d" }