hope_cache 0.1.5
hope_cache: ^0.1.5 copied to clipboard
Simple and fast caching for Dart/Flutter with TTL support, multiple eviction strategies, and pluggable storage.
0.1.2 #
- Initial release
- TTL support (default + per-key)
- Eviction policies: LRU, LFU, FIFO
- Map keys (React Query style)
- Batch operations (setMany, getMany)
- Pattern invalidation
- Pluggable storage interface
- In-memory storage implementation
0.1.3 #
Hope Query — New #
HopeBuilder— reactive widget for data fetching, no boilerplateHopeController— internal query engine with full lifecycle managementHopeClient— singleton registry, deduplicates controllers by keyHopeMutationController— handles write operations with callbacksHopeState— immutable state snapshot with typed flagsHopeOptions— query configuration
Query Features #
- Automatic caching with
staleTime— serve instantly, refresh in background - Retry with configurable count and delay
- Infinite scroll —
getNextPageParam,fetchMore,hasMore,pages refetchInterval— automatic background pollingrefetchOnResume— refetch when app comes to foreground, respectsstaleTimeenabled— conditional fetching for dependent queries- Reference counting — controllers disposed only when no widgets are listening
prefetch— warm cache before user navigates to a screeninvalidate— clears cache and forces fresh fetch on all listenersinvalidateAll— invalidate every active query at onceinvalidatePrefix— invalidate a group of related queriessetData— manually update controller state for optimistic updatesreset— reset mutation state back to idle
Cache Integration #
staleTimeworks alongside cache TTL — two independent freshness controls- Timestamp companion key (
__ts__) tracks when data was last fetched - Invalidation guarantees subsequent controllers always refetch fresh data