May 1, 2017 in Technical Problems
I've searched here and with Google and still don't have a clear picture of the persistence of \IPS\Data\Store::i()->myvar.
Some have said it is cached and could go away, others suggest using it for storing plugin variables. If cached how often is it cleared?
I'm using it to store weather data based on my user's location. When a user comes to site, if location is not in stored array, I fetch from weather provider, and store in an array with location,temp,icon,time. I then use this to generate weather info under everyone's profile. Need to store data to reduce calls to provider for performance and request limit reasons. I also check time of last update in array to avoid fetching from provider on every page access.
If the data were to go away every once in while, it will slowly rebuild, but I want to handle that case and fetch extra data. Also if it never clears then I need to do housekeeping on old results.
you can use in-build cache system
/* Get the result, reduce calls */
$result = \IPS\Data\Cache::i()->getWithExpire( 'wheather_today', TRUE );
catch ( \OutOfRangeException $e )
$result = \IPS\Http\Url::external( $endpoint )
'format' => 'json',
'url' => (string) $url->stripQueryString( 'autoplay' ),
'scheme' => ( $url->data['scheme'] === 'https' or \IPS\Request::i()->isSecure() ) ? 'https' : null
->request( static::$requestTimeout )
->setHeaders( array( 'Accept-Language' => \IPS\Member::loggedIn()->language()->short ) )
/* Store result into cache system with expiration */
\IPS\Data\Cache::i()->storeWithExpire( 'wheather_today', $result, \IPS\DateTime::create()->add( new \DateInterval( 'P1D' ) ), TRUE );
This topic is now archived and is closed to further replies.
Started 2 hours ago
Started Yesterday at 01:29 AM
Started Wednesday at 05:56 PM