使用predis包将缓存超时设置为Codeigniter中的密钥

时间:2016-02-08 12:13:52

标签: php codeigniter redis predis

在Codeigniter中,我使用Composer安装了predis软件包。我可以使用这个包设置并从缓存中获取值。我的要求是我需要使用Redis将值保留在缓存中1分钟。我看到通过Redis终端设置了不同的选项。但我需要在控制器本身设置时间限制。任何的想法 ?

2 个答案:

答案 0 :(得分:2)

只需使用EXPIRE通过predis:

$client = new Predis\Client();
$client->set('foo', 'bar');
$client->expire('foo', 60);

答案 1 :(得分:1)

您可以在一个命令中执行此操作:

struct Outer {
    struct Inner {
    };
};

template <typename T>
void test()
{
    ??Outer?? foo; // How do I get the type of T's outer class ?
}

test<Outer::Inner>();

但是为了获得最佳性能,您应该使用phpredis扩展,而不是predis库。

相关问题