Home  >  Q&A  >  body text

redis信息如何存储

假设每天都会有不少于1000000个唯一标识码进来系统,标识码组成结构是字符串+数字+下划线,形如"ua_124wtybmlo_cfk"。

现在需求是要判断某一个标识码三天内有没有在系统出现过。

如果用有效期是3天的string结构来存储每一个标识码,那么一天要有1000000+个string 类型的key,这样会非常消耗内存。

如果要优化的话,目前只能想到改为哈希结构+分片来存储,主要是分片策略不知如何制定。

不知道有没有哪位大神有什么好的方案?或者如果有其他好的优化方式也可以提出来。
感谢~

伊谢尔伦伊谢尔伦2707 days ago566

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-25 09:04:39

    Suppose a key-value occupies 32 bytes, and it only takes 90M in 3 days. Is this considered to consume a lot of memory?

    If you really care about memory and can ignore certain correctness, you can consider using Bloom filters.

    reply
    0
  • Cancelreply