guyeuro
V2EX  ›  问与答

频繁操作的数据用 redis 缓存还是自建缓存比较好?

  •  
  •   guyeuro · Aug 23, 2017 · 2070 views
    This topic created in 3257 days ago, the information mentioned may be changed or developed.

    java 项目,要用到两个数据结构

    1 {province : set<phonenumber>}

    2 {phonenumber: {"username": username, "status": status }}

    用的时候大致是时不时插入或者删除电话号码到 1 的 set 里(删除要用到定时机制或者超时机制)

    或者根据省份查 1 得到集合 set,然后在 2 里遍历这个电话号码的集合

    单项目使用,不用和其他服务共享数据

    自建缓存的话要用到 hashset hashmap/concurrenthashmap,还要定时器

    redis 的话直接用,但是用 redis 的性能和自建缓存比有明显差别吗?

    2 replies    2017-08-23 11:23:34 +08:00
    Muninn
        1
    Muninn  
       Aug 23, 2017
    redis 运维和将来扩展会麻烦一点
    自己写自己会麻烦一点 说不好缓存部分还出 bug 要修
    自己权衡了
    对了,自己写扩展分布式更麻烦。。。
    ofblyt
        2
    ofblyt  
       Aug 23, 2017
    自己做的轮子跑的快,还是别人都用的轮子跑的快,看需求
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2722 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:00 · PVG 20:00 · LAX 05:00 · JFK 08:00
    ♥ Do have faith in what you're doing.