Spring Batch 提供了一些非常有用的工具类(例如 JobLauncherTestUtils 和 JobRepositoryTestUtils)和测试执行监听器(StepScopeTestExecutionListener 和 JobScopeTestExecutionListener)来测试批量组件。然而, 为了能够使用这些工具类,你必须明确的对它们进行配置。这个发布介绍了一个新的注解,这个注解被命名为 @SpringBatchTest 能够自动的添加工具 bean(utility beans)和监听器(listeners)来测试上下文并且为自动写入来标记为可用,下面是一个示例代码:
@RunWith(SpringRunner.class)
@SpringBatchTest
@ContextConfiguration(classes = {JobConfiguration.class})
public class JobTest {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
@Autowired
private JobRepositoryTestUtils jobRepositoryTestUtils;
@Before
public void clearMetadata() {
jobRepositoryTestUtils.removeJobExecutions();
}
@Test
public void testJob() throws Exception {
// given
JobParameters jobParameters =
jobLauncherTestUtils.www.haomem178.cn getUniqueJobParameters();
// when
JobExecution jobExecution =
jobLauncherTestUtils.launchJob(www.mcyllpt.com jobParameters);
// then
Assert.assertEquals(ExitStatus.COMPLETED,
jobExecution.getExitStatus());
HTTP缓存类型
200 from cache:直接从本地缓存获取响应,可细分为from disk cache, from memory cache
304 Not Modified:协商缓存,本地未命中发送校验数据到服务端,如果服务端数据没有改变,则读取本地缓存响应
200 OK:不读取缓存,服务器返回完整响应
本地缓存相关Header(Response)
Pragma(1.0):设置为no-cache时会禁用本地缓存
Expires(1.0):值为格林威治时间,在这个时间前缓存有效无需发送请求
Cache-Control:缓存过期时间间隔
no-store:禁止缓存响应
no-cache:先发起请求和服务器协商,通过才能缓存响应
max-age=delta-seconds:告知浏览器该响应本地缓存有效的最长期限,以秒为单位
优先级:Pragma > Cache-control > Expires
协商缓存相关Header(Response)
Last-Modified:最后修改时间, If-Modified-Since(Request),发送到服务器的验证时间
ETag:文件的指纹标识符,随着文件内容改变而改变,If-None-Match(Request),发送到服务器的验证标识符
适合缓存的内容
直接缓存:js,css,图片,媒体文件
协商缓存:HTML,经常改变的js,css,图片,媒体文件
不适合缓存
用户隐私数据
经常改变的api接口数据
拒绝缓存:使用签名,如.js?签名
Nginx
add_header
本地缓存配置
expire:通知浏览器过期时长, expire time;
负值:cache-control:no-cache
正值:cache-control:max-age=指定时间
max:cache-control:max-age=10年后
协商缓存配置
Etag on|off,默认是on
}
转载于:https://www.cnblogs.com/qwangxiao/p/10291339.html