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


Java CacheControl.isProxyRevalidate方法代码示例

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


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

示例1: toString

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@Override
public String toString(final CacheControl value) {
    if (value == null) {
        return null;
    }

    final StringBuilder b = new StringBuilder();

    if (value.isPrivate()) {
        b.append("private");
    } else {
        b.append("public");
    }

    if (value.getMaxAge() >= 0) {
        b.append(", max-age=").append(value.getMaxAge());
    }
    if (value.getSMaxAge() >= 0) {
        b.append(", s-maxage=").append(value.getSMaxAge());
    }
    if (value.isMustRevalidate()) {
        b.append(", must-revalidate");
    }
    if (value.isNoCache()) {
        b.append(", no-cache");
    }
    if (value.isNoStore()) {
        b.append(", no-store");
    }
    if (value.isNoTransform()) {
        b.append(", no-transform");
    }
    if (value.isProxyRevalidate()) {
        b.append(", proxy-revalidate");
    }
    return b.toString();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:38,代码来源:MinijaxCacheControlDelegate.java

示例2: isCacheAcceptable

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
/**
 * Test if this request allows a specific cached response to be returned.
 *
 * @param request  the request context
 * @param now      instant that represents the current time
 * @param response response to check
 * @return true if the cached response can be returned, false if the request must be re-validated with the origin
 * server
 */
private static boolean isCacheAcceptable(CacheRequestContext request, DateTime now, CachedResponse response) {
    // NOTE: Do not check that the expiration time is before NOW here. That is verified later against the max-stale
    // cache-control option.
    DateTime responseDate = response.getDate();
    DateTime responseExpires = response.getExpires().get();

    if (responseExpires.isBefore(responseDate)) {
        return false;
    }

    RequestCacheControl requestCacheControl = request.getCacheControl();

    if (requestCacheControl.getMaxAge() > 0) {
        int age = Seconds.secondsBetween(responseDate, now).getSeconds();

        if (age > requestCacheControl.getMaxAge()) {
            return false;
        }
    }

    if (requestCacheControl.getMinFresh() >= 0 || requestCacheControl.getMaxStale() >= 0) {
        int freshness = Seconds.secondsBetween(now, responseExpires).getSeconds();

        if (requestCacheControl.getMinFresh() >= 0 && freshness < requestCacheControl.getMinFresh()) {
            return false;
        }

        if (requestCacheControl.getMaxStale() >= 0) {
            CacheControl responseCacheControl = response.getCacheControl().orNull();
            boolean responseMustRevalidate = responseCacheControl != null && (responseCacheControl.isProxyRevalidate() || responseCacheControl.isMustRevalidate());

            if (!responseMustRevalidate) {
                return freshness >= -requestCacheControl.getMaxStale();
            }
        }
    }

    return !responseExpires.isBefore(now);
}
 
开发者ID:bazaarvoice,项目名称:dropwizard-caching-bundle,代码行数:49,代码来源:ResponseCache.java


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