CACHE_EXPIRES_IN
Also known as
cache_expires (with or without @ prefix)
Set cache expiration time for cached endpoints.
Syntax
@cache_expires_in <interval>Uses interval format. Common examples:
| Format | Meaning |
|---|---|
10s | 10 seconds |
5m | 5 minutes |
1h | 1 hour |
1d | 1 day |
1w | 1 week |
Examples
Short Cache (10 seconds)
comment on function get_live_data() is
'HTTP GET
@cached
@cache_expires_in 10s';Medium Cache (5 minutes)
comment on function get_dashboard_stats() is
'HTTP GET
@cached
@cache_expires_in 5m';Long Cache (1 hour)
comment on function get_static_config() is
'HTTP GET
@cached
@cache_expires_in 1h';Daily Cache
comment on function get_daily_report() is
'HTTP GET
@cached
@cache_expires_in 1d';Related
- Interval Format - Complete interval format reference
- Cache Options configuration - Configure cache backend
- Comment Annotations Guide - How annotations work
- Configuration Guide - How configuration works
Related Annotations
- CACHED - Enable caching