Permalink
Browse files

added "add" method to YiiDebugCacheProxy

  • Loading branch information...
elvenpath committed May 21, 2014
1 parent 479e7df commit db5e7b57e3d5bf7323e670113e523e872f46e5bd
Showing with 26 additions and 0 deletions.
  1. +26 −0 YiiDebugCacheProxy.php
View
@@ -47,6 +47,7 @@ class YiiDebugCacheProxy extends CCache
'mget' => 0,
'mget_time' => 0,
'set' => 0, // write requests quantity
+ 'add' => 0, // add requests quantity
'set_time' => 0, // write time
'delete' => 0, // delete requests quantity
'delete_time' => 0, // delete time
@@ -156,6 +157,31 @@ public function set($id, $value, $expire = 0, $dependency = null)
return $returnValue;
}
+ /**
+ * Stores a value identified by a key into cache if the cache does not contain this key.
+ * Nothing will be done if the cache already contains the key.
+ * @param string $id the key identifying the value to be cached
+ * @param mixed $value the value to be cached
+ * @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire.
+ * @param ICacheDependency $dependency dependency of the cached item. If the dependency changes, the item is labeled invalid.
+ * @return boolean true if the value is successfully stored into cache, false otherwise
+ */
+ public function add($id,$value,$expire=0,$dependency=null)
+ {
+ if ($this->enableProfiling)
+ {
+ Yii::beginProfile(__METHOD__.'("'.$id.'")', $this->_logCategory.'.add');
+ }
+
+ $returnValue = $this->getCacheProxy()->add($id, $value, $expire, $dependency);
+
+ if ($this->enableProfiling)
+ {
+ ++$this->_stats['add'];
+ Yii::endProfile(__METHOD__.'("'.$id.'")', $this->_logCategory.'.add');
+ }
+ return $returnValue;
+ }
/**
* @see \CCache::delete
* @param string $id

0 comments on commit db5e7b5

Please sign in to comment.