Hi all I have a probably stupid question
# spicedb
b
Hi all, I have a (probably) stupid question re: ZedToken usage. I cache in redis the resource:id and latest returned ZedToken for the modification on that object type. Is that the best approach to use? If i dont do that i tend to hit the internal cache when i an stepping through wizard style processes and get 'false' responses when i should be getting 'true'.
v
I'm sure if I can qualify it as the best but what you are doing sounds right to me. ZedTokens are used primarily to address the new enemy problem, and for read-your-writes situations like what you describe. The Zanzibar paper recommends storing the zedtoken next to the actual resource, but that may not be feasible depending on your setup. You also need to consider what happens when the zedtoken is expired from Redis, in which case you may want to use
minimize_latency
or
fully_consistent
depending on your consistency needs. Writing to Redis and SpiceDB is a "dual-write" (crosses transactional boundaries) so you need to consider it's possible the Redis write may not have happened (e.g. process crashes after SpiceDB was written).
y
also if you're using redis as a cache in front of SpiceDB you're kinda caching your cache
v
it's not caching SpiceDB results but zedtokens, unless I misread?
19 Views