design patterns - state sharing with push & pull via redis -
i share state via redis following requirements:
- decoupling: uncoupled publishers , subscribers
- single ownership: each state set single publisher
- push: once state changes relevant subscribers must notified
- pull: once subscriber initializes should pull relevant states
if push required without pull pub\sub optimal
if pull required without push simple redis key , value work well
what best design pattern support requirements?
one solution use both pub\sub publish (push) state changes , hash keep latest published state of each kind subscriber can read (pull)
the hurdle need handle race conditions follows:
- publisher should notify , update state
- subscriber should first subscribe , read state
Comments
Post a Comment