duanlie2709 2016-11-18 10:41
浏览 158

GoLang的字符串映射键中是否有任何字符串长度限制?

Is there any maximum length of Go's string map key? Actually I use https://github.com/OneOfOne/cmap instead of Go's map.

The question is, the key I use in that cmap is about 200-4000 characters in length, will it be a problem/gotchas?

import "gitlab.com/kokizzu/gokil/I"
import "sync/atomic"

var CACHE_IDX int64
var CACHE_KEYS cmap.CMap

func init() {
    CACHE_KEYS = cmap.New()
}

// change a really long string to a shorter one 
func RamKey_ByQuery(query string) string {
    nkey := CACHE_KEYS.Get(query)
    if nkey != nil {
        return nkey.(string)
    }
    new_idx := atomic.AddInt64(&CACHE_IDX, 1)
    ram_key := `:` + I.ToS(new_idx) // convert integer to string
    CACHE_KEYS.Set(query, ram_key)
    return ram_key
}
  • 写回答

1条回答 默认 最新

  • dongpi9164 2016-11-18 10:55
    关注

    I think the only limit is your memory.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持