2017 © Pedro Peláez
 

library laravel4-psr6-cache-bridge

A PSR6 cache implementation for Laravel 4

image

superbalist/laravel4-psr6-cache-bridge

A PSR6 cache implementation for Laravel 4

  • Tuesday, July 4, 2017
  • by superbalist
  • Repository
  • 20 Watchers
  • 1 Stars
  • 3,385 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 20 % Grown

The README.md

laravel4-psr6-cache-bridge

A PSR6 cache implementation for Laravel 4., (*1)

Author Build Status StyleCI Software License Packagist Version Total Downloads, (*2)

This library is based off the Laravel 5 implementation by madewithlove/illuminate-psr-cache-bridge., (*3)

Installation

composer require superbalist/laravel4-psr6-cache-bridge

Register the service provider in app.php, (*4)

'providers' => [
    // ...
    'Superbalist\Laravel4PSR6CacheBridge\ServiceProvider'
]

Usage

You can now start using or injecting the CacheItemPoolInterface implementation for libraries which expect a PSR6 cache implementation., (*5)

use DateTimeImmutable;
use Psr\Cache\CacheItemPoolInterface;
use Superbalist\Laravel4PSR6CacheBridge\LaravelCacheItem::class;
use Superbalist\Laravel4PSR6CacheBridge\LaravelCacheItemPool::class;

$pool = app(CacheItemPoolInterface::class);
// or
$pool = app(LaravelCacheItemPool::class);

// save an item with an absolute ttl
$item = new LaravelCacheItem('first_name', 'Bob', true);
$item->expiresAt(new DateTimeImmutable('2017-06-30 14:30:00'));
$pool->save($item);

// save an item with a relative ttl
$item = new LaravelCacheItem('first_name', 'Bob', true);
$item->expiresAfter(60);
$pool->save($item);

// save an item permanently
$item = new LaravelCacheItem('first_name', 'Bob', true);
$pool->save($item);

// retrieve an item
$item = $pool->get('first_name');

// working with an item
var_dump($item->getKey());
var_dump($item->get());
var_dump($item->isHit());

// retrieve one or many items
$items = $pool->getItems(['first_name']);
var_dump($items['first_name']);

// check if an item exists in cache
var_dump($pool->hasItem('first_name'));

// wipe out all items
$pool->clear();

// delete an item
$pool->deleteItem('first_name');

// delete one or many items
$pool->deleteItems(['first_name']);

// save a deferred item
$item = new LaravelCacheItem('first_name', 'Bob', true);
$item->expiresAt(new DateTimeImmutable('+1 hour'));
$pool->saveDeferred($item);

// commit all deferred items
$pool->commit();

The Versions

04/07 2017

dev-master

9999999-dev

A PSR6 cache implementation for Laravel 4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

04/07 2017

1.0.1

1.0.1.0

A PSR6 cache implementation for Laravel 4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

03/07 2017

1.0.0

1.0.0.0

A PSR6 cache implementation for Laravel 4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd