我在 Spring Boot 应用程序中使用 Redis Cache 来存储多个 rest API 的数据。
我正在使用 Spring Cron 作业定期清除 Redis 缓存。该方法在所需的时隙被调用。
我已经验证了日志,但缓存没有清除,因此它显示了陈旧的数据。
我试图清除缓存的代码。
public class CustomerDerivation {
@Autowired
@Qualifier("redisCacheMngr")
CacheManager redisCacheMngr;
@Scheduled(cron = "${redis.api.update.interval}")
@CacheEvict(value = "redis-cache", allEntries = true, cacheNames = {"redis-cache"})
protected void cacheEvict() {
redisCacheMngr.getCache("redis-cache").clear();
logger.info("Evicting ModelCache");
}
}
Run Code Online (Sandbox Code Playgroud)
自定义缓存配置代码。
@Configuration
@Profile("cloud")
public class CacheConfig extends AbstractCloudConfig {
@Autowired
Environment env;
@Bean
public RedisConnectionFactory brRedisFactory() {
return connectionFactory().redisConnectionFactory(env.getProperty("model_cache_name"));
}
@Bean
public RedisTemplate<String, Object> brRedisTemplate() {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>(); …
Run Code Online (Sandbox Code Playgroud) 我想打开我的电话拨号器。但它显示错误。我已经在 Android Manifest 上声明了 CALL_PHONE 的权限,也在 Android Manifest 中声明了类。
case R.id.action_call:
Log.d("Action_call","INside Action call");
Intent dialer = new Intent(Intent.ACTION_DIAL);
startActivity(dialer);
return true;
Run Code Online (Sandbox Code Playgroud) 我有上个季度的季度结束日期让它成为30-09-20
,要求是找到下一个季度的结束日期即31-12-20
。我使用下面的代码来做同样的事情,但在某些情况下它会给出错误的输出。这个解决方案应该适用于所有方面。
String str = "30-09-20";
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yy");
Date date = format.parse(str);
Date newDate = DateUtils.addMonths(date, 3);
System.out.println(newDate);//Dec 30 - It should be 31 Dec
Run Code Online (Sandbox Code Playgroud) I have created 3 tabs . But when i switch between tabs the height of tab indicator is very small,it comes like a thin line over tabs.I have not seen any post that gives me solution of this problem.All of them are about how to change the colour of tab indicator.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_ACTION_BAR);
try {
setContentView(R.layout.activity_main);
ActionBar bar = getActionBar();
Log.d("In Tab Activity", bar.toString());
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Tab tab1 = bar.newTab();
tab1.setText("Contacts");
tab1.setTabListener(this);
bar.addTab(tab1);
Tab tab2 = …
Run Code Online (Sandbox Code Playgroud)