所有文档

          内容分发网络 CDN

          缓存管理

          刷新缓存

          public void purgeUrl(CdnClient client, String domainName) {
              PurgeRequest request = new PurgeRequest()
                      .addTask(new PurgeTask().withUrl(“http://+ domainName +/url”))
                      .addTask(new PurgeTask().withDirectory("http://" + domainName + "/directory/"));
              PurgeResponse purgeResponse = client.purge(request);
              System.out.println(purgeResponse);
              // 根据任务id查询刷新结果
              GetPurgeStatusResponse purgeStatusResponse = client.getPurgeStatus(
                       new GetPurgeStatusRequest().withId(purgeResponse.getId()));
              System.out.println(purgeStatusResponse);
          }

          查询刷新状态

           public void testGetPurgeStatus(String id) {
                  GetPurgeStatusRequest request = new GetPurgeStatusRequest().withId(id);
                  GetPurgeStatusResponse response = cdnClient.getPurgeStatus(request);
                  System.out.println(response);
              }

          预加载缓存&查询预加载状态

          /**预加载缓存*/
          public void testPrefetch() {
                  PrefetchRequest request = new PrefetchRequest()
                          .addTask(new PrefetchTask().withUrl("http://" + DOMAIN + "/url"));
                  PrefetchResponse response = cdnClient.prefetch(request);
                  System.out.println(response);
                  this.testGetPrefetchStatus(response.getId());
              }
           /** 查询预加载状态 */
          public void testGetPrefetchStatus(String id) {
                  GetPrefetchStatusResponse response = cdnClient.getPrefetchStatus(
                          new GetPrefetchStatusRequest().withId(id));
                  System.out.println(response);
              }

          查询限额

          public void getCacheQuota(){
                  GetCacheQuotaResponse response = cdnClient.getCacheQuota();
                  System.out.println(response);
              }

          操作记录-查询刷新和与预加载记录

          public void getCacheRecords(){
                  GetCacheRecordsRequest request=new GetCacheRecordsRequest().withType("all");
                  GetCacheRecordsResponse response = cdnClient.getCacheRecords(request);
                  System.out.println(response);
              }

          预热缓存

          public void prefetchUrl(CdnClient client, String domainName) {
              PrefetchRequest request = new PrefetchRequest()
                      .addTask(new PrefetchTask().withUrl(“http://+ domainName +/url”));
              PrefetchResponse prefetchResponse = client.prefetch(request);
              System.out.println(prefetchResponse);
              // 根据任务id查询预热结果
              GetPrefetchStatusResponse prefetchStatusResponse = client.getPrefetchStatus(
                       new GetPrefetchStatusRequest().withId(prefetchResponse.getId()));
              System.out.println(prefetchStatusResponse);
          }
          上一篇
          统计与日志接口
          下一篇
          动态加速接口