https://github.com/infobiotech/php-json-cache
A JSON-based PSR-16 cache implementation.
https://github.com/infobiotech/php-json-cache
cache flysystem json php7 psr-16
Last synced: about 2 months ago
JSON representation
A JSON-based PSR-16 cache implementation.
- Host: GitHub
- URL: https://github.com/infobiotech/php-json-cache
- Owner: infobiotech
- License: mit
- Created: 2017-11-05T09:26:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-13T17:11:13.000Z (over 8 years ago)
- Last Synced: 2025-01-25T12:41:29.929Z (over 1 year ago)
- Topics: cache, flysystem, json, php7, psr-16
- Language: PHP
- Homepage:
- Size: 113 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://infobiotech.net?ibtref=github-readme-header)
# infobiotech/php-json-cache
[](https://php.net/)
[](https://packagist.org/packages/infobiotech/php-json-cache)
[](https://packagist.org/packages/infobiotech/php-json-cache)
[](https://packagist.org/packages/infobiotech/php-json-cache)
[](https://packagist.org/packages/infobiotech/php-json-cache)
[](https://packagist.org/packages/infobiotech/php-json-cache)
A key-value JSON-based PSR-16 cache implementation.
Built with:
* [PHP-FIG PSR-16](http://www.php-fig.org/psr/psr-16/): a common interface for caching libraries.
* [Psr\SimpleCache](https://github.com/php-fig/simple-cache): a repository that holds all interfaces related to PSR-16.
* [League\Flysystem](https://flysystem.thephpleague.com/): a filesystem abstraction that allows to easily swap out a local filesystem for a remote one.
---
Here our Quality Assurance indicators for `master` git branch.
| | build status | code coverage | code quality |
| ------------ | ------------ | ------------- | ------------ |
| Travis CI | [](https://travis-ci.org/infobiotech/php-json-cache) | | |
| CodeCov | | [](https://codecov.io/gh/infobiotech/php-json-cache) | |
| Scrutinizer | [](https://scrutinizer-ci.com/g/infobiotech/php-json-cache/build-status/master) | | [](https://scrutinizer-ci.com/g/infobiotech/php-json-cache/?branch=master) |
| Code Climate | | | [](https://codeclimate.com/github/infobiotech/php-json-cache/maintainability) |
| Codacy | | [](https://www.codacy.com/app/alessandroraffa/php-json-cache?utm_source=github.com&utm_medium=referral&utm_content=infobiotech/php-json-cache&utm_campaign=Badge_Coverage) | [](https://www.codacy.com/app/alessandroraffa/php-json-cache?utm_source=github.com&utm_medium=referral&utm_content=infobiotech/php-json-cache&utm_campaign=Badge_Grade) |
---
## Why JSON?
* In some situations, remote web hosts do not support (or do not allow to install) major cache drivers.
* JSON objects allow to set/get key-value items.
## Getting Started
### Prerequisites
* PHP 5.6 or greater (including 7.0, 7.1 and [HHVM](https://hhvm.com/))
### Installing via composer
Make sure you have [composer](http://getcomposer.org/) installed.
Then run the following command from your project root:
```sh
$ composer require infobiotech/php-json-cache
```
## Usage
**infobiotech/php-json-cache** implements [PSR-16](http://www.php-fig.org/psr/psr-16/) and thus provides a standardized API for storing and retrieving data.
Here is a simple use case:
```php
set('key', 'value'); // return TRUE
$jsonCache->get('key'); // return 'value'
```
### Migrations
#### From v0.x to v1.x
Due to a deep refactor and restructure, the instantiation code must change from this:
```php
$jsonCache = new Infobiotech\JsonCache(/* your adapter and your namespace */);
```
to this:
```php
$jsonCache = new Infobiotech\JsonCache\Psr16\Driver(/* your adapter and your namespace */);
```
The API is unchanged.
## Other PSR-16 implementations
* [sabre-io/cache](https://github.com/sabre-io/cache) - In-memory, APCu and Memcached cache abstraction layer.
* [matthiasmullie/scrapbook](https://github.com/matthiasmullie/scrapbook) - Full featured caching environment with several adapters.
* [SilentByte/litecache](https://github.com/SilentByte/litecache) - Lightweight code/opcode caching by generating `*.php` files for cached objects.
* [kodus/file-cache](https://github.com/kodus/file-cache) - Flat-file cache-implementation.
* [naroga/redis-cache](https://github.com/naroga/redis-cache) - A Redis driver implementation.
* [paillechat/apcu-simple-cache](https://github.com/paillechat/apcu-simple-cache) - APCu implementation.
* [kodus/mock-cache](https://github.com/kodus/mock-cache) - A PSR-16 mock cache for integration testing.
## Tests
### Running Tests
Run the following command from your project root:
```sh
$ ./vendor/bin/phpunit
```
### Running PHP Code Sniffer
Run the following command from your project root:
```sh
$ ./vendor/bin/phpcs src --standard=psr2 -sp
```
## Versioning
We try to follow [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/infobiotech/php-json-cache/tags).
## Authors
* **Alessandro Raffa** - *Initial work* - [infobiotech](https://github.com/infobiotech)
## Contributing
Contributions are welcome and will be credited.
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct.
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details