public static function hasCachedConfig($filepath)
 {
     logDebug("Looking in memcache for {$filepath}");
     if (!function_exists("memcache_connect")) {
         return false;
     }
     $key = LinkedDataApiCache::configCacheKey($filepath);
     $mc = memcache_connect(PUELIA_MEMCACHE_HOST, PUELIA_MEMCACHE_PORT);
     $cachedObject = $mc->get($key);
     if ($cachedObject) {
         return $cachedObject;
     }
     logDebug("No cached version of ConfigGraph from {$filepath}");
     return false;
 }
Beispiel #2
0
        $ConfigGraph->init();
        if ($selectedEndpointUri = $ConfigGraph->getEndpointUri()) {
            logDebug("Endpoint Uri Selected: {$selectedEndpointUri}");
            unset($CompleteConfigGraph);
            $Response = new LinkedDataApiResponse($Request, $ConfigGraph, $HttpRequestFactory);
            $Response->process();
            break;
        } else {
            if ($docPath = $ConfigGraph->dataUriToEndpointItem($Request->getUri())) {
                logDebug("Redirecting " . $Request->getUri() . " to {$docPath}");
                header("Location: {$docPath}", 303);
                exit;
            }
        }
    }
    if (!isset($selectedEndpointUri)) {
        logDebug("No Endpoint Selected");
        $Response = new LinkedDataApiResponse($Request, $CompleteConfigGraph);
        if ($Request->getPathWithoutExtension() == $Request->getInstallSubDir() . CONFIG_PATH) {
            logDebug("Serving ConfigGraph");
            $Response->serveConfigGraph();
        } else {
            logDebug("URI Requested:" . $Request->getPathWithoutExtension());
            $Response->process();
        }
    }
}
$Response->serve();
if (defined("PUELIA_SERVE_FROM_CACHE") and $Response->cacheable) {
    LinkedDataApiCache::cacheResponse($Request, $Response);
}
 private function decideToCheckTripleStore($pathWithoutExtension)
 {
     $this->useDatastore = $this->ConfigGraph->get_first_literal($this->ConfigGraph->getEndpointUri(), API . 'enableCache');
     $this->useDatastore = $this->useDatastore === 'true' ? true : false;
     if ($this->useDatastore == true) {
         //if caching is enabled
         if (defined("PUELIA_SERVE_FROM_CACHE") and PUELIA_SERVE_FROM_CACHE) {
             if ($cachedResponse = LinkedDataApiCache::hasCachedUri($pathWithoutExtension)) {
                 //request without format is cached
                 // we get the data from the datastore
                 $checkDatastore = true;
             } else {
                 //we go directly to the external service
                 $checkDatastore = false;
             }
         } else {
             // try to get the data from the datastore
             $checkDatastore = true;
         }
     } else {
         $checkDatastore = false;
     }
     return $checkDatastore;
 }