【发布时间】:2012-11-11 13:48:55
【问题描述】:
以这段代码为例:
public function actionPostOneWay( $postId )
{
$dependency = new CDbCacheDependency( 'SELECT publish_date FROM posts WHERE id = :post_id;' );
$dependency->params = array( 'post_id'=>$postId );
$post = Post::model()->cache( 59, $dependency )->findByPk( $postId );
// process post one way
}
public function actionPostAnotherWay( $postId )
{
$dependency = new CDbCacheDependency( 'SELECT publish_date FROM posts WHERE id = :post_id;' );
$dependency->params = array( 'post_id'=>$postId );
$post = Post::model()->cache( 59, $dependency )->findByPk( $postId );
// process post another way
}
那么访问/postOneWay 和/postAnotherWay 会重用同一个缓存对象,还是会创建自己的缓存对象?
【问题讨论】: