How to cache with unlimited duration time?

Documentation states that the duration property of the cache component defaults to 60 if it is not set explicitly. But if i want the cache to live forever ('cause i invalidate or unset its id manually is some controller actions) how can i do that? Which value do i need to pass to the duration propery?

If i'm not mistaken, i think that a cached pair cannot live forever. An item gets expired either when it's expiration time has passed or when you're trying to store a new pair in a full cache, the least used item with expiration time closer to this moment will get expired (even if it's expiration time haven't passed yet).

I suppose that your only option is to update the pair with a new expiration time before it expires.

One of the document says 0 means never expire.

http://www.yiiframew…ache#add-detail

Quote

One of the document says 0 means never expire.

http://www.yiiframew…ache#add-detail

yes but with the $this->beginCache() widget there is no expire option…only a duration option

duration cannot be set as forever. Use a sufficiently large duration should be good enough.

Quote

yes but with the $this->beginCache() widget there is no expire option...only a duration option

I see.

@Qiang

Is there any reason that there are two different parameters such as expire and duration, while those two are almost the same?

Quote

Quote

yes but with the $this->beginCache() widget there is no expire option...only a duration option

I see.

@Qiang

Is there any reason that there are two different parameters such as expire and duration, while those two are almost the same?

exactly. And also why with the CController::beginCache() we cannot have the expire option to have the cache that never expire?

no particular reason…call it a design flaw? ;)