Skip to content

PHPPlatform/json-cache

Repository files navigation

PHP Platform Caching JSON Meta Data

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages