jaredchu/simple-cache
Composer 安装命令:
composer require jaredchu/simple-cache
包简介
Simple PHP object caching base on temp file
README 文档
README
Simple PHP object caching base on temp file
Installation
$ composer require jaredchu/simple-cache
Usage
Quick start
use JC\Cache\SimpleCache; // store your object SimpleCache::add('your-key', new Person('Jared', 27)); // check if exists SimpleCache::exists('your-key'); // fetch your object $person = SimpleCache::fetch('your-key', Person::class); // remove your cache SimpleCache::remove('your-key');
Add
// cache object Person with lifetime 1000 seconds (default is 0, not expire) SimpleCache::add('your-key', new Person('Jared', 27), 1000);
Fetch
if(SimpleCache::exists('your-key')){ $person = SimpleCache::fetch('your-key', Person::class); $person->sayHi(); }
Remove
SimpleCache::remove('your-key');
Security
// your data is already encrypt but you can set your own encrypt key SimpleCache::setEncryptKey('your unique string'); SimpleCache::add('your-key', new Person('Jared', 27)); // you must set encrypt key again if you want to call fetch in another session SimpleCache::setEncryptKey('your unique string'); $person = SimpleCache::fetch('your-key', Person::class);
Contributing
- Fork it!
- Create your feature branch:
$ git checkout -b feature/your-new-feature - Commit your changes:
$ git commit -am 'Add some feature' - Push to the branch:
$ git push origin feature/your-new-feature - Submit a pull request.
License
统计信息
- 总下载量: 1.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-04