cacheTime property

Duration cacheTime
final

How long inactive cache data remains in memory before garbage collection

When a query becomes inactive (no active listeners), it stays in memory for this duration before being removed. This is separate from staleTime:

  • staleTime: Controls when data is considered "stale" (needs refetch)
  • cacheTime: Controls when data is removed from memory (garbage collected)

Example:

ZenQueryConfig(
  staleTime: Duration(seconds: 30),  // Stale after 30s
  cacheTime: Duration(minutes: 5),   // Kept in memory for 5min
)
  • Set to Duration.zero to immediately remove when inactive
  • Set to a large value to keep in memory longer
  • Default: 5 minutes

Implementation

final Duration cacheTime;