design patterns - state sharing with push & pull via redis -


i share state via redis following requirements:

  1. decoupling: uncoupled publishers , subscribers
  2. single ownership: each state set single publisher
  3. push: once state changes relevant subscribers must notified
  4. 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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -