Dani Diprana
03/12/2024, 1:13 PMDani Diprana
03/12/2024, 1:15 PMMatthew Ramotar
03/13/2024, 12:08 AMvalidator
. The validator
checks local data before emitting it and refreshes the data when it’s not validDani Diprana
03/13/2024, 1:08 AMstore.clear("key")
.. Is it correct?Dani Diprana
03/13/2024, 1:48 AMttl
but I don't see when the data should expire and delete the data from SOT?
I mean, there is no relation between ttl
on the validator and data eviction. Ttl
is only being used to decide want to use data from SOT or not. CMIIWMatthew Ramotar
03/13/2024, 2:07 PMMy understanding is we can have any logic and when we want to clear the data we only callYes. You can use.. Is it correct?store.clear("key")
store.clear("key")
to manually remove data for a specific key from both the memory cache and SOT. This is useful when you know that a particular piece of data is no longer needed or should be refreshed.
Also, in the store example, there is abut I don’t see when the data should expire and delete the data from SOT?ttl
I mean, there is no relation betweenIn that example,on the validator and data eviction.ttl
is only being used to decide want to use data from SOT or not. CMIIWTtl
ttl
is used by validator
to determine whether to serve data from the SOT or fetch fresh data. Fetching fresh data replaces the stale data for the associated key.
Do you have any suggestions on how to proper manage the eviction of SOT data?If you want to automatically evict data from your SOT based on a TTL, you’ll need to implement that logic within the SOT itself. For example, if you’re delegating to Room for your SOT, you could: 1. Add a
@Query
annotation and a timestamp field. Periodically delete stale data from a WorkManager job.
2. Use Room’s maxSize
parameter when creating your database. Room will automatically remove older data to stay under the limit.
How you manage data eviction will depend on your particular needs. But in general, the Store lib is designed to work in conjunction with your chosen SOT, not replace its functionality.Dani Diprana
03/13/2024, 2:44 PMMike Nakhimovich
03/25/2024, 11:29 PMMike Nakhimovich
03/25/2024, 11:30 PM