Exemplo n.º 1
0
 public static function getCache()
 {
     if (self::$_cache == null) {
         if (file_exists(dirname(__DIR__) . '/cache.dat')) {
             self::$_cache = unserialize(file_get_contents(dirname(__DIR__) . '/cache.dat'));
         }
         if (self::$_cache == null || self::$_cache == false) {
             self::$_cache = GIS::generateFullCache();
             file_put_contents(dirname(__DIR__) . '/cache.dat', serialize(self::$_cache));
         }
     }
     return self::$_cache;
 }
 public function setUp()
 {
     $this->_simpleCache = \GISwrapper\GIS::generateSimpleCache(__DIR__ . '/assets/shortened/docs.json');
     $this->_fullCache = \GISwrapper\GIS::generateFullCache(__DIR__ . '/assets/shortened/docs.json');
 }
Exemplo n.º 3
0
 * caching.php
 * generate the cache, write it to a file, retrieve the cache from a file and instantiate the GIS wrapper with the cache
 *
 * +++ Please copy the config.example.php to config.php and edit it accordingly
 *
 * @author Karl Johann Schubert
 * @version 0.1
 */
require dirname(__DIR__) . '/vendor/autoload.php';
require __DIR__ . '/config.php';
/**
 * Generate the full cache and write it to $filename
 */
$filename = __DIR__ . '/cache.dat';
// generate the cache array
$cache = \GISwrapper\GIS::generateFullCache();
// serialize the array to get a string
$cachestring = serialize($cache);
// write it to a file
file_put_contents($filename, $cachestring);
/**
 * Get the full cache from $filename and instantiate the GIS wrapper
 */
$cachestring = file_get_contents($filename);
$cache = unserialize($cachestring);
$user = new \GISwrapper\AuthProviderEXPA(EXPA_USER, EXPA_PW);
$gis = new \GISwrapper\GIS($user, $cache);
/**
 * one-liner
 *
 * generate file: file_put_contents($filename, serialize(\GISwrapper\GIS::generateFullCache()));