CacheConfig class

Cache configuration for endpoints. Defines cache behavior including TTL, size limits, and error caching.

Example

// Custom config
final config = CacheConfig(
  enabled: true,
  ttl: Duration(minutes: 10),
  maxSize: 200,
  cacheErrors: false,
);

// Use preset
final quickConfig = CacheConfig.short;

Constructors

CacheConfig({bool enabled = true, Duration ttl = const Duration(minutes: 5), int maxSize = 100, bool cacheErrors = false})
const

Properties

cacheErrors bool
Cache error responses.
final
enabled bool
Caching enabled.
final
hashCode int
The hash code for this object.
no setterinherited
maxSize int
Max cached entries.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
ttl Duration
Time to live for cached responses.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

disabled → const CacheConfig
No caching.
long → const CacheConfig
Long cache (30 min).
medium → const CacheConfig
Medium cache (5 min).
short → const CacheConfig
Short cache (1 min).