当前位置:网站首页>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 the Chinese Valentine's day in 2022? Practical and beautiful gift recommendation
![[c语言]--一步一步实现扫雷小游戏](/img/ee/49ddfcd948ccd5c8c9dec3c48c6112.png)
[c语言]--一步一步实现扫雷小游戏

关于Shader KeyWord的整理

如何模拟实现strcpy库函数

SSAO By Computer Shader(一)

Treasure plan TPC system development DAPP construction
![[PTA----输出全排列]](/img/66/d1699cd55fa5ff4a55e3e150d02c1b.png)
[PTA----输出全排列]

Two dimensional array practice: spiral matrix

SSAO By Computer Shader(二)
随机推荐
Leetcode 刷题日记 剑指 Offer II 055. 二叉搜索树迭代器
valgrind工具
动态规划--简单题型之爬楼梯
【无标题】
OJ 1505 fuse
Leetcode brush question diary sword finger offer II 053. Medium order successor in binary search tree
OJ 1505 保险丝
Execjs call
[basic knowledge of binary tree]
Pyppeteer is recognized to bypass detection
OJ 1045 反转然后相加
AQS之countDownLatch源码分析
【C语言】字符串库函数介绍及模拟
OJ 1451 数字游戏
【二叉树基础知识】
SSAO By Computer Shader(一)
Battle plague Cup -- my account book
数组解法秘籍
动态规划--多步爬楼梯(爬楼梯进阶版)
What is the best and most cost-effective open headset recommended