gitee.com/quant1x/engine@v1.8.4/cache/cache_code.go (about) 1 package cache 2 3 import ( 4 "fmt" 5 "gitee.com/quant1x/exchange" 6 ) 7 8 // CacheId 通过代码构建目录结构 9 func CacheId(code string) string { 10 _, marketName, code := exchange.DetectMarket(code) 11 cacheId := fmt.Sprintf("%s%s", marketName, code) 12 return cacheId 13 } 14 15 // CacheIdPath code从后保留3位, 市场缩写+从头到倒数第3的代码, 确保每个目录只有000~999个代码 16 func CacheIdPath(code string) string { 17 N := 3 18 cacheId := CacheId(code) 19 length := len(cacheId) 20 21 prefix := cacheId[:length-N] 22 return fmt.Sprintf("%s/%s", prefix, cacheId) 23 }