Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaredchu/simple-cache
Simple PHP object caching base on temp file (no additional PHP extension require)
https://github.com/jaredchu/simple-cache
cache composer composer-package packagist php php7
Last synced: 3 months ago
JSON representation
Simple PHP object caching base on temp file (no additional PHP extension require)
- Host: GitHub
- URL: https://github.com/jaredchu/simple-cache
- Owner: jaredchu
- License: mit
- Created: 2017-08-03T10:18:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-24T10:29:37.000Z (over 6 years ago)
- Last Synced: 2024-10-10T23:04:35.273Z (3 months ago)
- Topics: cache, composer, composer-package, packagist, php, php7
- Language: PHP
- Homepage:
- Size: 44.9 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-cache
Simple PHP object caching base on temp file[![Packagist](https://img.shields.io/packagist/v/jaredchu/simple-cache.svg)](https://packagist.org/packages/jaredchu/simple-cache)
[![Packagist](https://img.shields.io/packagist/dt/jaredchu/simple-cache.svg)](https://packagist.org/packages/jaredchu/simple-cache)
[![Travis](https://img.shields.io/travis/jaredchu/Simple-Cache.svg)](https://travis-ci.org/jaredchu/Simple-Cache)
[![Scrutinizer](https://img.shields.io/scrutinizer/g/jaredchu/Simple-Cache.svg)](https://scrutinizer-ci.com/g/jaredchu/Simple-Cache/)
[![Codecov](https://img.shields.io/codecov/c/github/jaredchu/Simple-Cache.svg)](https://codecov.io/gh/jaredchu/simple-cache)
[![Packagist](https://img.shields.io/packagist/l/jaredchu/simple-cache.svg)](https://packagist.org/packages/jaredchu/simple-cache)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjaredchu%2FSimple-Cache.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjaredchu%2FSimple-Cache?ref=badge_shield)## Installation
`$ composer require jaredchu/simple-cache`## Usage
#### Quick start
```PHP
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
```PHP
// cache object Person with lifetime 1000 seconds (default is 0, not expire)
SimpleCache::add('your-key', new Person('Jared', 27), 1000);
```
#### Fetch
```PHP
if(SimpleCache::exists('your-key')){
$person = SimpleCache::fetch('your-key', Person::class);
$person->sayHi();
}
```
#### Remove
```PHP
SimpleCache::remove('your-key');
```
#### Security
```PHP
// 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
1. Fork it!
2. Create your feature branch: `$ git checkout -b feature/your-new-feature`
3. Commit your changes: `$ git commit -am 'Add some feature'`
4. Push to the branch: `$ git push origin feature/your-new-feature`
5. Submit a pull request.## License
[MIT License](https://github.com/jaredchu/Simple-Cache/blob/master/LICENSE)[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjaredchu%2FSimple-Cache.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjaredchu%2FSimple-Cache?ref=badge_large)