php-platform/json-cache

There is no license information available for the latest version (v0.1.2) of this package.

v0.1.2 2017-03-31 09:46 UTC

This package is not auto-updated.

Last update: 2024-04-13 23:20:09 UTC


README

Whole PHP Platform is built by using Meta Data in JSON Format. This package provides caching for JSON Metadata

Build Status

Usage

  • 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();

Extending the cache

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;
	}
}

Example

Please see the test TestCache for more examples