コード例 #1
0
 public static function cacheResponse(LinkedDataApiRequest $request, LinkedDataApiResponse $response)
 {
     if (!function_exists("memcache_connect")) {
         return false;
     }
     $cacheableResponse = new LinkedDataApiCachedResponse();
     $cacheableResponse->eTag = $response->eTag;
     $cacheableResponse->generatedTime = $response->generatedTime;
     $cacheableResponse->lastModified = $response->lastModified;
     $cacheableResponse->mimetype = $response->mimetype;
     $cacheableResponse->body = $response->body;
     $key = LinkedDataApiCache::cacheKey($request->getOrderedUriWithoutApiKeys(), $cacheableResponse->mimetype);
     logDebug('Caching Response as ' . $key . ' with mimetype ' . $cacheableResponse->mimetype);
     $mc = memcache_connect(PUELIA_MEMCACHE_HOST, PUELIA_MEMCACHE_PORT);
     $mc->add($key, $cacheableResponse, false, PUELIA_CACHE_AGE);
 }