codeigniter-redis icon indicating copy to clipboard operation
codeigniter-redis copied to clipboard

How can i set time for expire.

Open hardik-tatvasoft opened this issue 8 years ago • 3 comments

Hello,

How can i set particular cache for particular time. ?

I have tried using this : $this->redis->set('foo2', 'bar',500); but its not working. please some one look in to this.

Thanks, Hardik Devariya

hardik-tatvasoft avatar Sep 18 '17 10:09 hardik-tatvasoft

You'll want to check the Redis commands list on redis.io to see what's wrong, here.

The short answer is that set doesn't support including an expiration. You'll need to use setex instead.

danhunsaker avatar Sep 18 '17 17:09 danhunsaker

Hello i have checked it using https://redis.io/commands/setex and it works fine on the redis cli.

but how can i use using php codeigniter code i have tried this : $this->redis->setex('foo2', 'bar',500);

but it still not work from ci.

hardik-tatvasoft avatar Sep 19 '17 05:09 hardik-tatvasoft

If you look again at the command docs, you'll see that order matters, here.

danhunsaker avatar Sep 19 '17 06:09 danhunsaker