WeatherCache
in package
uses
TraitData, TraitDataWrite
Read onlyYes
FinalYes
Table of Contents
Constants
- CACHE_DURATION = 86400
- FORECAST_MAX_DAYS = 14
Properties
- $date : string
- $latitude : float
- $longitude : float
Methods
- __construct() : mixed
- getDataInstance() : Data
- getDataWriteInstance() : DataWrite
- getWeather() : array<string|int, mixed>|null
- Get cached weather data or return null if invalid/expired
- setWeather() : void
- Store weather data in cache table
- shouldCacheForDate() : bool
- Check if we should attempt to cache weather data for this date
- getKey() : string
- Generate key
- isValidCache() : bool
- Verify if cached data is still valid
Constants
CACHE_DURATION
private
mixed
CACHE_DURATION
= 86400
FORECAST_MAX_DAYS
private
mixed
FORECAST_MAX_DAYS
= 14
Properties
$date
private
string
$date
$latitude
private
float
$latitude
$longitude
private
float
$longitude
Methods
__construct()
public
__construct([float $latitude = 0 ][, float $longitude = 0 ][, string $date = '' ]) : mixed
Parameters
- $latitude : float = 0
- $longitude : float = 0
- $date : string = ''
getDataInstance()
public
getDataInstance() : Data
Return values
DatagetDataWriteInstance()
public
getDataWriteInstance() : DataWrite
Return values
DataWritegetWeather()
Get cached weather data or return null if invalid/expired
public
getWeather() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullsetWeather()
Store weather data in cache table
public
setWeather(array<string|int, mixed> $forecast) : void
Parameters
- $forecast : array<string|int, mixed>
shouldCacheForDate()
Check if we should attempt to cache weather data for this date
public
shouldCacheForDate(string $date) : bool
Parameters
- $date : string
Return values
boolgetKey()
Generate key
private
getKey() : string
Return values
stringisValidCache()
Verify if cached data is still valid
private
isValidCache(array<string|int, mixed> $data) : bool
Parameters
- $data : array<string|int, mixed>