如何实现 Redis 多级缓存的更新?
怪我咯
怪我咯 2017-04-22 08:56:32
0
2
844

分布式开发中,使用 Redis 做二级缓存,本地静态对象做一级缓存,如何实现二级缓存被更新时通知一级缓存?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all (2)
小葫芦

I have not used distributed ones in actual development. Let’s discuss it with you.
My thoughts are:

  1. Use redis Pub/Sub method to subscribe to the updates of the secondary cache. When a machine updates the cache, thenPub一个Key,通知所有的客户端,客户端前往更新,刷新一级缓存。key的值可以按机器号:数据key,这样搞,通过机器号判断让更新者不要更新,其它机器更新,数据keyupdate the specified data.
  2. Consider whether the first-level cache is really needed. Will not using the first-level cache cause any problems? If it is a performance issue that can be ignored, I tend to use redis directly as the first-level cache, saving time, effort and complexity :)
    Ty80

    The background scheduled task synchronizes the redis cache to the memory cache

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!