2017 © Pedro Peláez
 

yii2-extension yii2-php-file-cache

Yii 2 PHP file cache

image

sergeymakinen/yii2-php-file-cache

Yii 2 PHP file cache

  • Monday, February 12, 2018
  • by sergeymakinen
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,090 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 12 % Grown

The README.md

Yii 2 PHP file cache

Yii 2 cache component that uses native PHP files to store cache data so:, (*1)

  • it's possible to improve a PHP performance by storing a precompiled data bytecode in a shared memory (objects will be serialized though)
  • allows to include an arbitrary PHP code to bootstrap something
  • it's fully compatible with the standard Yii 2 cache interface

Code Quality Build Status Code Coverage SensioLabsInsight, (*2)

Packagist Version Total Downloads Software License, (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

composer require "sergeymakinen/yii2-php-file-cache:^2.0"

or add, (*6)

"sergeymakinen/yii2-php-file-cache": "^2.0"

to the require section of your composer.json file., (*7)

Usage

Set the following Yii 2 configuration parameters:, (*8)

[
    'components' => [
        'phpCache' => [
            'class' => 'sergeymakinen\yii\phpfilecache\Cache',
        ],
    ],
]

And you can use it like any Yii 2 cache class:, (*9)

Yii::$app->phpCache->set('foo', 'bar')

Caching values with a PHP code

If you need to execute any PHP bootstrap code before you get a value from a cache, pass a sergeymakinen\yii\phpfilecache\ValueWithBootstrap instance with the value and a PHP code (which can be multiline of course) as a string to set():, (*10)

use sergeymakinen\yii\phpfilecache\ValueWithBootstrap;

Yii::$app->phpCache->set(
    'foo',
    new ValueWithBootstrap(
        'bar',
        'Yii::$app->params[\'fromCache\'] = true;'
    )
);

Since version 1.1 you can also pass a Closure instead of a PHP code:, (*11)

use sergeymakinen\yii\phpfilecache\ValueWithBootstrap;
use yii\helpers\StringHelper;

Yii::$app->phpCache->set(
    'foo',
    new ValueWithBootstrap('bar', function () {
        \Yii::$app->params['fromCache'] = true;
        \Yii::$app->params['name'] = StringHelper::basename('/etc/config');
    })
)

The Versions

12/02 2018

dev-master

9999999-dev https://github.com/sergeymakinen/yii2-php-file-cache

Yii 2 PHP file cache

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache php yii2 caching yii yii2-php-file-cache

12/02 2018

v2.1.0

2.1.0.0 https://github.com/sergeymakinen/yii2-php-file-cache

Yii 2 PHP file cache

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache php yii2 caching yii yii2-php-file-cache

06/01 2017

v2.0.0

2.0.0.0 https://github.com/sergeymakinen/yii2-php-file-cache

Yii 2 PHP file cache

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache php yii2 caching yii yii2-php-file-cache

03/01 2017

v1.1.0

1.1.0.0 https://github.com/sergeymakinen/yii2-php-file-cache

Yii 2 PHP file cache

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache php yii2 caching yii yii2-php-file-cache

16/12 2016

v1.0.0

1.0.0.0 https://github.com/sergeymakinen/yii2-php-file-cache

Yii 2 PHP file cache

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache php yii2 caching yii yii2-php-file-cache