remove redundant cache prefix
[pharext/pharext.org] / app / Github / API / Call.php
index ea9b59a70c461e7d0837e6e650c0eaf8c408e573..32bf1cb0c89bd7e46aa9c0ad70727c55fb8afd06 100644 (file)
@@ -57,16 +57,11 @@ abstract class Call
        }
        
        function __invoke(callable $callback) {
-               if (empty($this->args["fresh"]) && ($cache = $this->api->getCacheStorage())) {
-                       $key = $this->getCacheKey();
-                       
-                       if ($cache->get($key, $cached)) {
-                               call_user_func_array($callback, $cached);
-                               return $this->api->getClient();
-                       }
+               if ($this->readFromCache($cached)) {
+                       call_user_func_array($callback, $cached);
+               } else {
+                       $this->enqueue($callback);
                }
-               
-               $this->enqueue($callback);
                return $this;
        }
        
@@ -102,7 +97,7 @@ abstract class Call
                $args = $this->args;
                unset($args["fresh"]);
                ksort($args);
-               return sprintf("github:%s:%s:%s", $this->api->getToken(), $this, 
+               return sprintf("%s:%s:%s", $this->api->getToken(), $this, 
                        new QueryString($args));
        }
 
@@ -119,7 +114,7 @@ abstract class Call
                        if (isset($this->config->storage->cache->{$this}->ttl)) {
                                $ttl = $this->config->storage->cache->{$this}->ttl;
                        } else {
-                               $ttl = 0;
+                               $ttl = null;
                        }
                        
                        $key = $this->getCacheKey();