ttl_cache is a lightweight, Flutter-compatible package that provides a key-value store with automatic expiration of entries based on a user-defined time-to-live (TTL). It enables efficient temporary data storage by removing stale entries after their TTL expires, reducing memory usage and ensuring data freshness. Ideal for caching API responses, session data, or any transient information. The package supports all major platforms including Android, iOS, Web, and desktop environments.
Use cases
- Caching API responses
- Storing session tokens
- Temporary data persistence
- Reducing redundant network calls
- Managing short-lived configuration
- Improving app performance
Key features
- Automatic entry expiration
- Cross-platform support
- Simple key-value interface
- Configurable TTL per entry
- Memory-efficient design
- Thread-safe operations
Suitable for
- Apps needing short-term data storage
- Developers seeking lightweight caching
- Projects requiring automatic cleanup
- Real-time data with freshness guarantees
- High-performance applications
Considerations
- Entries are not persisted across app restarts
- TTL precision depends on system clock
- Not suitable for long-term storage
- No built-in serialization
- Limited to in-memory storage
- Requires manual management of large datasets