当前位置: 首页>>代码示例>>Java>>正文


Java CacheConfig.setMaxCacheEntries方法代码示例

本文整理汇总了Java中org.apache.http.impl.client.cache.CacheConfig.setMaxCacheEntries方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfig.setMaxCacheEntries方法的具体用法?Java CacheConfig.setMaxCacheEntries怎么用?Java CacheConfig.setMaxCacheEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.impl.client.cache.CacheConfig的用法示例。


在下文中一共展示了CacheConfig.setMaxCacheEntries方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStorage

import org.apache.http.impl.client.cache.CacheConfig; //导入方法依赖的package包/类
private HttpCacheStorage createStorage()
{
    CacheConfig config = new CacheConfig();
    // if max cache entries value is not present the CacheConfig's default (CacheConfig.DEFAULT_MAX_CACHE_ENTRIES = 1000) will be used
    Integer maxCacheEntries = Integer.getInteger("bitbucket.client.cache.maxentries");
    if (maxCacheEntries != null)
    {
        config.setMaxCacheEntries(maxCacheEntries);
    }
    return new BasicHttpCacheStorage(config);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:12,代码来源:HttpClientProvider.java

示例2: tex2json

import org.apache.http.impl.client.cache.CacheConfig; //导入方法依赖的package包/类
private static String tex2json(String tex) throws IOException {
    CachingHttpClientBuilder cachingHttpClientBuilder = CachingHttpClientBuilder.create();
    CacheConfig cacheCfg = new CacheConfig();
    cacheCfg.setMaxCacheEntries(100000);
    cacheCfg.setMaxObjectSize(8192);
    cachingHttpClientBuilder.setCacheConfig(cacheCfg);
    HttpClient client = cachingHttpClientBuilder.build();
    //HttpPost post = new HttpPost("http://localhost/convert");
    HttpPost post = new HttpPost("https://drmf-latexml.wmflabs.org");
    List<NameValuePair> nameValuePairs = new ArrayList<>(1);
    nameValuePairs.add(new BasicNameValuePair("tex",
        "$" + tex + "$"));
    //WARNING: This does not produce pmml, since there is a xstl trasformation that rewrites the output and removes pmml
//	      nameValuePairs.add(new BasicNameValuePair("profile",
//		          "mwsquery"));
    nameValuePairs.add(new BasicNameValuePair("preload",
        "mws.sty"));
    nameValuePairs.add(new BasicNameValuePair("profile",
        "math"));
    nameValuePairs.add(new BasicNameValuePair("noplane1",
        ""));
    nameValuePairs.add(new BasicNameValuePair("whatsout",
        "math"));
    post.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));
    HttpResponse response = client.execute(post);
    BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    String line = "";
    String result = "";
    while ((line = rd.readLine()) != null) {
      result += line;
    }
    return result;
  }
 
开发者ID:ag-gipp,项目名称:mathosphere,代码行数:34,代码来源:TeX2MathML.java

示例3: SimpleHttpClient

import org.apache.http.impl.client.cache.CacheConfig; //导入方法依赖的package包/类
/**
 * Creates a HTTP client.
 * 
 * @param parent
 *            Owning object. Used for logging.
 * @param maxCacheEntries
 *            the maximum number of cache entries the cache will retain. Set to 0 for no caching.
 */
public SimpleHttpClient(Object parent, int maxCacheEntries) {
    logger = Logger.getLogger(this.getClass().getName() + "-" + instanceCounter.incrementAndGet() + " ("
            + parent.getClass().getSimpleName() + ")");

    isShutdown = new AtomicBoolean();

    PoolingClientConnectionManager conman = new PoolingClientConnectionManager();
    // increase max number of connections per host and total, defaults are too low to take advantage of multiple
    // threads
    conman.setDefaultMaxPerRoute(50); // default is 2
    conman.setMaxTotal(100); // default is 20
    defaultClient = new DefaultHttpClient(conman);

    if (maxCacheEntries > 0) {
        CacheConfig cacheConfig = new CacheConfig();
        cacheConfig.setSharedCache(false);
        cacheConfig.setMaxCacheEntries(maxCacheEntries);
        cachingClient = new CachingHttpClient(defaultClient, cacheConfig);
        theClient = cachingClient;
    } else {
        cachingClient = null;
        theClient = defaultClient;
    }

    logger.info("Created");
}
 
开发者ID:fgavilondo,项目名称:neo4j-webgraph,代码行数:35,代码来源:SimpleHttpClient.java

示例4: initialize

import org.apache.http.impl.client.cache.CacheConfig; //导入方法依赖的package包/类
@PostConstruct
protected void initialize() {
    try {
        lock.writeLock().lock();

        httpParams = new BasicHttpParams();
        String userAgentString =
                "Apache Marmotta/" + configurationService.getStringConfiguration("kiwi.version") +
                " (running at " + configurationService.getServerUri() + ")" +
                " lmf-core/" + configurationService.getStringConfiguration("kiwi.version");
        userAgentString = configurationService.getStringConfiguration("core.http.user_agent", userAgentString);

        httpParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, configurationService.getIntConfiguration("core.http.so_timeout", 60000));
        httpParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                configurationService.getIntConfiguration("core.http.connection_timeout", 10000));

        httpParams.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true);
        httpParams.setIntParameter(ClientPNames.MAX_REDIRECTS, 3);

        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
        schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

        PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
        cm.setMaxTotal(configurationService.getIntConfiguration(CoreOptions.HTTP_MAX_CONNECTIONS, 20));
        cm.setDefaultMaxPerRoute(configurationService.getIntConfiguration(CoreOptions.HTTP_MAX_CONNECTIONS_PER_ROUTE, 10));

        final DefaultHttpClient hc = new DefaultHttpClient(cm, httpParams);
        hc.setRedirectStrategy(new LMFRedirectStrategy());
        hc.setHttpRequestRetryHandler(new LMFHttpRequestRetryHandler());
        hc.removeRequestInterceptorByClass(org.apache.http.protocol.RequestUserAgent.class);
        hc.addRequestInterceptor(new LMFRequestUserAgent(userAgentString));

        if (configurationService.getBooleanConfiguration(CoreOptions.HTTP_CLIENT_CACHE_ENABLE, true)) {
            CacheConfig cacheConfig = new CacheConfig();
            // FIXME: Hardcoded constants - is this useful?
            cacheConfig.setMaxCacheEntries(1000);
            cacheConfig.setMaxObjectSize(81920);

            final HttpCacheStorage cacheStore = new MapHttpCacheStorage(httpCache);

            this.httpClient = new MonitoredHttpClient(new CachingHttpClient(hc, cacheStore, cacheConfig));
        } else {
            this.httpClient = new MonitoredHttpClient(hc);
        }
        bytesSent.set(0);
        bytesReceived.set(0);
        requestsExecuted.set(0);

        idleConnectionMonitorThread = new IdleConnectionMonitorThread(httpClient.getConnectionManager());
        idleConnectionMonitorThread.start();

        StatisticsProvider stats = new StatisticsProvider(cm);
        statisticsService.registerModule(HttpClientService.class.getSimpleName(), stats);
    } finally {
        lock.writeLock().unlock();
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:59,代码来源:HttpClientServiceImpl.java

示例5: HttpCache

import org.apache.http.impl.client.cache.CacheConfig; //导入方法依赖的package包/类
public HttpCache() {

        CacheConfig cacheCfg =new CacheConfig();
        cacheCfg.setMaxCacheEntries(1000);
        cacheCfg.setMaxObjectSize(8192);

        cachingClient = new CachingHttpClient(new DefaultHttpClient(), cacheCfg);

    }
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:10,代码来源:HttpCache.java


注:本文中的org.apache.http.impl.client.cache.CacheConfig.setMaxCacheEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。