Permalink
Browse files

added clear() method. rebuild .phar package. bump version

  • Loading branch information...
1 parent 18221bf commit 12e0f2c6ba860d6bded7cb48727d69f69ad3d655 @thousandsofthem thousandsofthem committed Mar 1, 2013
Showing with 25 additions and 2 deletions.
  1. +20 −2 IronCache.class.php
  2. +5 −0 TestCache.php
  3. BIN iron_cache.phar
View
@@ -5,7 +5,7 @@
* @link https://github.com/iron-io/iron_cache_php
* @link http://www.iron.io/products/cache
* @link http://dev.iron.io/
- * @version 0.1.0
+ * @version 0.1.1
* @package IronCache
* @copyright Feel free to copy, steal, take credit for, or whatever you feel like doing with this code. ;)
*/
@@ -106,7 +106,7 @@ public function asArray() {
}
class IronCache extends IronCore{
- protected $client_version = '0.1.0';
+ protected $client_version = '0.1.1';
protected $client_name = 'iron_cache_php';
protected $product_name = 'iron_cache';
protected $default_values = array(
@@ -335,6 +335,24 @@ public function increment($key, $amount = 1){
return $this->incrementItem($this->cache_name, $key, $amount);
}
+ /**
+ * Clear a Cache
+ * Delete all items in a cache. This cannot be undone.
+ *
+ * @param string|null $cache Cache name or null
+ * @return mixed
+ */
+ public function clear($cache = null) {
+ if ($cache === null){
+ $cache = $this->cache_name;
+ }
+ $cache = self::encodeCache($cache);
+ $url = "projects/{$this->project_id}/caches/$cache/clear";
+ $params = array();
+ $this->setJsonHeaders();
+ return self::json_decode($this->apiCall(self::POST, $url, $params));
+ }
+
function session_open($savePath, $sessionName){
$this->setCacheName($sessionName);
View
@@ -37,6 +37,11 @@
$item = $cache->get($key);
var_dump($item);
+ echo "\nClear cache:\n";
+ $res = $cache->clear();
+ var_dump($res);
+
+
echo "----$i----\n";
}
View
Binary file not shown.

0 comments on commit 12e0f2c

Please sign in to comment.