Multiple Caches Per Page 每页多个缓存
You can have multiple cache files for a single call to display() or fetch(). Let's say that a call to display('index.tpl') may have several different output contents depending on some condition, and you want separate caches for each one. You can do this by passing a cache_id as the second parameter to the function call.
你可以用单个函数display()或fetch()来输出多个缓存文档。display('index.tpl')在多种条件下会有不同的输出内容,要单独的把缓存分开。可以通过函数的第二参数cache_id来达到效果。
Example 14-6. passing a cache_id to display()
Above, we are passing the variable $my_cache_id to display() as the cache_id. For each unique value of $my_cache_id, a separate cache will be generated for index.tpl. In this example, "article_id" was passed in the URL and is used as the cache_id.
Be sure to pass the same cache_id as the second parameter to is_cached() and clear_cache().
|