Whole PHP Platform is built by using Meta Data in JSON Format. This package provides caching for JSON Metadata
- to read from cache
PhpPlatform\JSONCache\Cache::getInstance()->getData($key);
where $key
is string representaion of json path for required cached value
- to store in cache
PhpPlatform\JSONCache\Cache::getInstance()->setData($data);
where $data
is an array
to be stored in the cache
- to reset cache
PhpPlatform\JSONCache\Cache::getInstance()->reset();
PhpPlatform\JSONCache\Cache
can be extended to create user defined caches
class NewCache extends PhpPlatform\JSONCache\Cache{
private static $cacheObj = null;
protected $cacheFileName = "newcachefile"; // new cache filename
public static function getInstance(){
if(self::$cacheObj == null){
self::$cacheObj = new NewCache();
}
return self::$cacheObj;
}
}
Please see the test TestCache for more examples