当前位置:网站首页>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+"");
});
}
}
}
边栏推荐
- redis实现分布式锁思路及redission分布式锁主流程分析
- redis缓存设计与性能优化
- 【二叉树基础知识】
- 【动态规划--买卖股票的最佳时期系列2】
- 空气传导耳机哪个牌子好、备受好评的气传导耳机推荐
- Graphic pipeline foundation (II)
- 2022-06-07 VI. log implementation
- SSAO By Computer Shader(二)
- [pta---- output full arrangement]
- Leetcode brush question diary sword finger offer II 048. serialization and deserialization binary tree
猜你喜欢

[PTA--利用队列解决猴子选大王问题】

气传导耳机哪个品牌比较好、这四款不要错过

下雨场景效果(一)

Treasure plan TPC system development DAPP construction

什么气传导蓝牙耳机好、配置比较高的气传导耳机推荐

What is hash? (development of Quantitative Trading Robot System)

Leetcode brush questions diary sword finger offer II 047. Binary tree pruning

mongoDB复制集及分片集群

SSAO by computer shader (II)

C语言的编译和预处理
随机推荐
【实现简易版扫雷小游戏】
战疫杯--奇奇怪怪的形状
刷题记录----二叉树的层序遍历
OJ 1131 beautiful number
AQS之countDownLatch源码分析
[c语言]简易通讯录的实现
浮点型数据在内存中如何存储
【动态规划--买卖股票的最佳时期系列3】
Bug experience related to IAP jump of stm32
C语言的编译和预处理
C语言memcpy库函数与memmove的作用
江中ACM新生10月26日习题题解
订单交易简析
@PostConstruct注解及用处示例
STM32的IAP跳转相关bug经历
结构体、位段、联合体(共用体)的大小如何计算
动态规划--多步爬楼梯(爬楼梯进阶版)
OJ 1089 Spring Festival travel
Leetcode 刷题日记 剑指 Offer II 048. 序列化与反序列化二叉树
2022-07-17 Damon database installation