最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I set up Redis to publish to a pubsub channel when a key-value is changed? - Stack Overflow

programmeradmin3浏览0评论

Can I set up Redis to publish to a pub/sub channel when a key-value is changed?

Is there anyway to monitor these changes automatically or do I just need to build it in a part of the set to broadcast the new value?

Thanks!

Can I set up Redis to publish to a pub/sub channel when a key-value is changed?

Is there anyway to monitor these changes automatically or do I just need to build it in a part of the set to broadcast the new value?

Thanks!

Share Improve this question asked Sep 15, 2011 at 3:33 fancyfancy 51.4k64 gold badges156 silver badges230 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

That sort of thing is too plex/not generic enough to be built in to redis, but it is easier to do as part of your client anyway - just send a PUBLISH mand after the SET.

Note that unlike SUBSCRIBE, PUBLISH does not require a dedicated connection so is easily integrated with other mands.

As of Redis 2.8.0, there is support for KeySpace Notifications, which do exactly what you want. You can read more about it here - http://redis.io/topics/notifications

KeySpace notifications are a little cpu intensive, so are disabled by default. For simpler tasks, doing what @tom-clarkson said above should suffice.

发布评论

评论列表(0)

  1. 暂无评论