Skip to content

Instantly share code, notes, and snippets.

@phpnode
Created March 22, 2012 11:35
Show Gist options
  • Save phpnode/2157822 to your computer and use it in GitHub Desktop.
Save phpnode/2157822 to your computer and use it in GitHub Desktop.
<?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