Caching Zookies per app instance
# spicedb
v
So in my app, I would like to provide a default experience where consistency uses
minimizeLatency
and
atLeastAsFresh
when no zookie is provided. This would mean I need to cache a recent enough zookie in my backend and use that when none is provided. 1. Does this make sense? 2. Should I be concerned about this with respect to the New Enemy Problem? 3. Does the Node client support this out-of-the-box? 4. Is it better to middleware my call chain or listen to the event stream from SpiceDB?
y
> where consistency uses
minimizeLatency
and
atLeastAsFresh
when no zookie is provided if you're using
minimizeLatency
then you don't need to be holding onto a zedtoken. i also think the question of "what happens the first time a user calls the application" kinda sidesteps the new enemy problem - the new enemy problem is asking "what happens if i lose access to something that i previously had access to?" our recommendation if the new enemy problem is a concern is to store a zedtoken in the row that represents the object in question, and then when you want to determine whether a user has access to a thing, you fetch it from the DB and then make an
at_least_as_fresh
call with the zedtoken that you pulled out of the DB. this ensures that the check is made as of the last time the object is modified, which is sufficient to prevent the new enemy problem (and i can elaborate on the "why" of that if desired)
v
yeah, I realized the minLatency thing is different from asFresh, so the default is asFresh, and I think having an atomic string in the app instance ought to work when non is specified. It starts as fullConsistency until it sees the first zookie
24 Views