当前位置:网站首页>Initializingbean interface and examples
Initializingbean interface and examples
2022-07-28 06:44:00 【yfyh2021】
Definition
InitializingBean Interface for bean Provides a way to initialize methods , It only includes afterPropertiesSet Method , All classes that inherit this interface , Initializing bean This method will be implemented when .
Example
Load the full amount of data into the bloom filter
@Slf4j
@Configuration
public class BloomFilterConfig implements InitializingBean{
@Autowired
private PmsProductService productService;
@Autowired
private RedisTemplate template;
@Bean
public BloomFilterHelper<String> initBloomFilterHelper() {
return new BloomFilterHelper<>((Funnel<String>) (from, into) -> into.putString(from, Charsets.UTF_8)
.putString(from, Charsets.UTF_8), 1000000, 0.01);
}
/**
* The bloon filter bean Inject
* @return
*/
@Bean
public BloomRedisService bloomRedisService(){
BloomRedisService bloomRedisService = new BloomRedisService();
bloomRedisService.setBloomFilterHelper(initBloomFilterHelper());
bloomRedisService.setRedisTemplate(template);
return bloomRedisService;
}
@Override
public void afterPropertiesSet() throws Exception {
List<Long> list = productService.getAllProductId();
log.info(" Load the product into the bloom filter ,size:{}",list.size());
if(!CollectionUtils.isEmpty(list)){
list.stream().forEach(item->{
//LocalBloomFilter.put(item);
bloomRedisService().addByBloomFilter(RedisKeyPrefixConst.PRODUCT_REDIS_BLOOM_FILTER,item+"");
});
}
}
}
边栏推荐
- 数组解法秘籍
- What's a good gift for your girlfriend on Chinese Valentine's day? Boys who can't give gifts, look!
- 做气传导耳机最好的是哪家、最好的气传导耳机盘点
- Ready to start blogging
- Leetcode 刷题日记 剑指 Offer II 055. 二叉搜索树迭代器
- AQS之ReentrantLock源码解析
- [pta ---- traversal of tree]
- OJ 1089 春运
- Network communication and tcp/ip protocol
- Valgrind tool
猜你喜欢

图形管线基础(番外篇)

AQS之ReentrantLock源码解析

Icc2 (IV) routing and postroute optimization

What are the open earphones? Four types of air conduction earphones with excellent sound quality are recommended

Leetcode 刷题日记 剑指 Offer II 055. 二叉搜索树迭代器

SSAO By Computer Shader(二)

Everything you don't know about time complexity is here

SSAO by computer shader (III)

气传导蓝牙耳机怎么样、最值得入手的气传导耳机

关于时间复杂度,你不知道的都在这里
随机推荐
2022-06-07 VI. log implementation
Battle plague Cup -- strange shape
图形管线基础(二)
订单交易简析
New Selenium
feignclient @RequestMapping参数设置及请求头简易方式设置
[c语言]简易通讯录的实现
What's a good gift for your girlfriend on the Chinese Valentine's day in 2022? Practical and beautiful gift recommendation
[dynamic planning -- the best period series for buying and selling stocks]
Leetcode 刷题日记 剑指 Offer II 050. 向下的路径节点之和
【动态规划--买卖股票的最佳时期系列2】
OJ 1507 deletion problem
网络通信及TCP/IP协议
RayMarching realizes volume light rendering
刷题记录----哈希表
About the collation of shader keyword
valgrind工具
What is the best and most cost-effective open headset recommended
OJ 1451 digital games
【自我救赎的开始】