当前位置:网站首页>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+"");
});
}
}
}
边栏推荐
- OJ 1284 记数问题
- Battle plague Cup -- strange shape
- [pta-- use queues to solve the problem of monkeys choosing kings]
- Graphic pipeline foundation (I)
- OJ 1131 beautiful number
- New Selenium
- Getting started with hugging face
- Mysql-8.0.17-winx64 (additional Navicat) manual configuration version installation
- OJ 1507 deletion problem
- What's a good gift for your girlfriend on Chinese Valentine's day? Boys who can't give gifts, look!
猜你喜欢
随机推荐
OJ 1253 ordering problem
水渲染示例
刷题记录----链表
[pta-- use queues to solve the problem of monkeys choosing kings]
C语言的编译和预处理
NFT data storage blind box + mode system development
[basic knowledge of binary tree]
RayMarching实现体积光渲染
代码整洁之道(二)
[dynamic planning -- the best period for buying and selling stocks Series 2]
江中ACM新生10月26日习题题解
JS variable is equal to 0, etc. '
Ready to start blogging
OJ 1129 fraction matrix
Development of Quantitative Trading Robot System
redis实现分布式锁思路及redission分布式锁主流程分析
Leetcode skimming diary sword finger offer II 050. sum of downward path nodes
What are the open earphones? Four types of air conduction earphones with excellent sound quality are recommended
费马小定理
准备开始写博客了


![[c语言]简易通讯录的实现](/img/75/8f2f4dd1c166808047cda6bea5a746.png)



![[dynamic planning -- the best period series for buying and selling stocks]](/img/90/9060eabc9b9e7f660504806fde282d.png)

![[pta---- output full arrangement]](/img/66/d1699cd55fa5ff4a55e3e150d02c1b.png)