表结构说明
字段名称
字段描述
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) ;
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) ;
}
removeTags. removeAll ( dbTags) ;
for ( String tag :</