Skip to main content

set_cache_owner

Function set_cache_owner 

Source
pub async fn set_cache_owner(owner: Option<String>)
Expand description

Tells the cache whose data it holds: the signed-in user’s id, or None when signed out. Call it whenever the signed-in user is known or changes, including on sign-out.

When the owner differs from the one the persistent store was written for, or is None, the whole cache (memory and store) is emptied, so one person never sees another’s lists on a shared device.

Pass None only once you know nobody is signed in, never while still finding out: it empties the cache, so an app that says “nobody” before its session check answers starts every launch cold. Resolve the user on the server (use_server_future), or wait for the check.

Until this is first called, the cache keeps everything in memory only. An app that never calls it is still safe, just without instant cold starts. A store written in an earlier run is still read on a cold start before this is called: it only ever holds the data of whoever was signed in last, and this empties it if that is no longer the case.