Leaf关键源码解析

表结构说明

字段名称 字段描述
biz_tag 业务标识
max_id 号段最大值
step 号段最小步长
description 描述信息
update_time 号段切换时间

缓存初始化

logger.info("update cache from db");
StopWatch sw = new Slf4JStopWatch();
try {
   
    List<String> dbTags = dao.getAllTags();
    if (dbTags == null || dbTags.isEmpty()) {
   
        return;
    }
    List<String> cacheTags = new ArrayList<String>(cache.keySet());
    List<String> insertTags = new ArrayList<String>(dbTags);
    List<String> removeTags = new ArrayList<String>(cacheTags);
    //db中新加的tags灌进cache
    insertTags.removeAll(cacheTags);
    for (String tag : insertTags) {
   
        SegmentBuffer buffer = new SegmentBuffer();
        buffer.setKey(tag);
        Segment segment = buffer.getCurrent();
        segment.setValue(new AtomicLong(0));
        segment.setMax(0);
        segment.setStep(0);
        cache.put(tag, buffer);
        logger.info("Add tag {} from db to IdCache, SegmentBuffer {}", tag, buffer);
    }
    //cache中已失效的tags从cache删除
    removeTags.removeAll(dbTags);
    for (String tag :</
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值