Created
March 22, 2012 11:35
-
-
Save phpnode/2157822 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ActiveRecord { | |
public static function generateCacheKey($field, $id = null) | |
{ | |
return get_class(static::model()).($id !== null ? ':'.$id : '').':'.$field; | |
} | |
public function getCacheKey($field) | |
{ | |
return self::generateCacheKey($field,$this->getPrimaryKey()); | |
} | |
public function invalidateCache($field) | |
{ | |
Yii::app()->cache->delete($this->getCacheKey($field)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment