php-platform / json-cache
此包的最新版本(v0.1.2)没有可用的许可证信息。
v0.1.2
2017-03-31 09:46 UTC
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: ~4.8
This package is not auto-updated.
Last update: 2024-09-29 01:38:02 UTC
README
整个PHP平台是使用JSON格式的元数据构建的。此包提供JSON元数据的缓存
使用方法
- 从缓存中读取
PhpPlatform\JSONCache\Cache::getInstance()->getData($key);
其中 $key
是所需缓存的JSON路径的字符串表示
- 存储到缓存
PhpPlatform\JSONCache\Cache::getInstance()->setData($data);
其中 $data
是要存储在缓存中的 数组
- 重置缓存
PhpPlatform\JSONCache\Cache::getInstance()->reset();
扩展缓存
PhpPlatform\JSONCache\Cache
可以扩展以创建用户定义的缓存
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; } }
示例
请参阅测试 TestCache 获取更多示例