2017 © Pedro Peláez
 

yii2-extension yii2-cached-dataprovider

Cached data provider

image

tugmaks/yii2-cached-dataprovider

Cached data provider

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

The README.md

Yii2 DataProvider caching decorator

Simple decorator for dataprovider, (*1)

Installation

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

Either run, (*3)

php composer.phar require --prefer-dist tugmaks/yii2-cached-dataprovider "0.1"

or add, (*4)

"tugmaks/yii2-cached-dataprovider": "0.1"

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

Usage example

First, you need to configure CacheResolver service in container, (*6)

'singletons' => [
        'cache'                               => function () {
            return \Yii::$app->cache;
        },
        'cache_resolver.naming_strategy.caching_item_name' => [
            ['class' => \Tugmaks\Dataprovider\DefaultCacheKeyNamingStrategy::class],
            [
                'caching_item_name',
            ],
        ],
        'cache_resolver.caching_item_name'                 => [
            ['class' => \Tugmaks\Dataprovider\CacheResolver::class],
            [
                Instance::of('cache'),
                Instance::of('cache_resolver.naming_strategy.caching_item_name'),
                //Additionally you can pass cache ttl and dependecy
            ],
        ],
    ],

Second, instead of passing yii\data\DataProviderInterface object directly to data widget, you have to decorate it in this way:, (*7)

use use Tugmaks\Dataprovider\CachedDataProvider;

$cacheResolver = \Yii::$container->get('cache_resolver.caching_item_name');

$cachedDataProvider = new CachedDataProvider($dataProvider, $cacheResolver);

Now pass $cachedDataProvider to data widget., (*8)

The Versions

12/02 2018

dev-master

9999999-dev

Cached data provider

  Sources   Download

MIT

The Requires

 

by Maxim Tyugaev

yii2 cached dataprovider

12/02 2018

0.1

0.1.0.0

Cached data provider

  Sources   Download

MIT

The Requires

 

by Maxim Tyugaev

yii2 cached dataprovider