Giter VIP home page Giter VIP logo

cache's Introduction

CodeIgniter 4 PSR Cache

PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4

Coverage Status

Disclaimer: CodeIgniter 4 comes with a fully-functional cache component! This module is only for integrating third-party packages that rely on the PSR interface provisions.

Quick Start

  1. Install with Composer: > composer require codeigniter4/cache
  2. Integrate with your favorite packages:
use CodeIgniter\Psr\Cache\SimeplCache;
use Kreait\Firebase\Factory;
...

$factory = (new Factory)->withVerifierCache(new SimpleCache());

Features

A set of adapters fully-compliant with PSR-6 and PSR-16 to integrate with CodeIgniter 4's Caching Driver.

Installation

Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

  • > composer require codeigniter4/cache

Or, install manually by downloading the source files and adding the directory to app/Config/Autoload.php.

Usage

This module has adapters for CodeIgniter 4 to supply the following FIG PHP Standards Recommendations (PSR):

If you just need a caching agent then you should use the framework's native Caching Driver. These adapters are intended to integrate with any library or project that requires either of the following:

The interfaces are provided by the following classes:

  • Psr\Cache\CacheItemInterface provided by CodeIgniter\Psr\Cache\Item
  • Psr\Cache\CacheItemPoolInterface provided by CodeIgniter\Psr\Cache\Pool
  • Psr\SimpleCache\CacheInterface provided by CodeIgniter\Psr\Cache\SimpleCache

By default the adapters (Pool and SimpleCache) will work with the Caching Driver as defined in you cache configuration (e.g. app/Config/Cache.php). You may create either driver explicitly with an alternative Cache Handler or Config:

    $sharedCacheServicePool = new \CodeIgniter\Psr\Cache\Pool();

    $fileHandler = new \CodeIgniter\Cache\Handlers\FileHandler(config('Cache'));
    $explicitFileHandlerSimpleCache = new \CodeIgniter\Psr\Cache\SimpleCache($fileHandler);

    $config = config('Cache');
    $config->prefix = 'banana-';
    $alternativeConfigPool = new \CodeIgniter\Psr\Cache\Pool($config);

Testing

Testing of the underlying Caching Driver is handled in the CodeIgniter 4 repo. These adapters are tested with the PHP Cache Integration Tests, by Aaron Scherer. You may run the test suite by cloning this repo, installing all dependencies, and running:

  • > composer test

cache's People

Contributors

kenjis avatar mgatner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.