infobiotech/php-json-cache

JSON-based PSR-16 cache implementation.

v1.0.1-alpha 2017-11-09 01:24 UTC

README

"infobiotech logo"

infobiotech/php-json-cache

Minimum PHP Version Latest Stable Version Latest Unstable Version Total Downloads composer.lock License

A key-value JSON-based PSR-16 cache implementation.

Built with:

  • PHP-FIG PSR-16: a common interface for caching libraries.
  • Psr\SimpleCache: a repository that holds all interfaces related to PSR-16.
  • League\Flysystem: 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 Build Status
CodeCov codecov
Scrutinizer Build Status Scrutinizer Code Quality
Code Climate Maintainability
Codacy Codacy Badge Codacy Badge

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)

Installing via composer

Make sure you have composer installed.

Then run the following command from your project root:

$ composer require infobiotech/php-json-cache

Usage

infobiotech/php-json-cache implements PSR-16 and thus provides a standardized API for storing and retrieving data.

Here is a simple use case:

<?php

require 'vendor/autoload.php';

$flysystemAdapter = new League\Flysystem\Adapter\Local('.');

$jsonCache         = new Infobiotech\JsonCache\Psr16\Driver($flysystemAdapter, uniqid());

$jsonCache->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:

$jsonCache = new Infobiotech\JsonCache(/* your adapter and your namespace */);

to this:

$jsonCache = new Infobiotech\JsonCache\Psr16\Driver(/* your adapter and your namespace */);

The API is unchanged.

Other PSR-16 implementations

Tests

Running Tests

Run the following command from your project root:

$ ./vendor/bin/phpunit

Running PHP Code Sniffer

Run the following command from your project root:

$ ./vendor/bin/phpcs src --standard=psr2 -sp

Versioning

We try to follow SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Contributing

Contributions are welcome and will be credited.

Please read CONTRIBUTING.md for details on our code of conduct.

License

This project is licensed under the MIT License - see the LICENSE.md file for details