sidnt / zionotes

⸮ 🔴zio notes | zio nursery 🔵?
0 stars 0 forks source link

inmemory db with stm #13

Open sidnt opened 4 years ago

sidnt commented 4 years ago

stm/tref can very well act as an inmemory concurrent datastore for our app. but there might be a few gotchas.

given situation:

to modify the state dag, as a first cut, we can call something like

def update(trS:TRef[State], p:Patch):UIO[Unit] =
  STM.atomically {
    for {
      _  <- trS.update(oldState => getNewState(oldState, p))
    } yield ()
  }

proposition: that ^ is not the best strategy to use, if we frequently need to update different subgraphs in the DAG, which have 0 nodes in common.