2017-25 © Pedro Peláez
 

library caching-object-wrapper

Wraps up any PHP object so all its methods are cached.

image

rapidwebltd/caching-object-wrapper

Wraps up any PHP object so all its methods are cached.

  • Thursday, March 22, 2018
  • by DivineOmega
  • Repository
  • 4 Watchers
  • 4 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

🎁 Caching Object Wrapper

Build Status Coverage Status StyleCI, (*1)

Wraps up any PHP object so all its methods are cached., (*2)

Installation

You can install this package easily via Composer. Just run the following command from the root of your project., (*3)

composer require rapidwebltd/caching-object-wrapper

Usage

Here is a very simple usage example, showing how we can easily cache a simple object., (*4)

use RapidWeb\CachingObjectWrapper\CachingObjectWrapper;
use rapidweb\RWFileCachePSR6\CacheItemPool;

// This is an example class that we are going to use. It just generates random numbers.
class RandomNumberGenerator
{
    public function generate()
    {
        return rand();
    }
}

// First, we need to install and setup a PSR6 cache item pool. 
// As an example, we'll use the PSR-6 adapter for RW File Cache.

// $ composer require rapidwebltd/rw-file-cache-psr-6

$cache = new CacheItemPool();
$cache->changeConfig(
    [
        'cacheDirectory'  => '/tmp/cow-tests/',
        'gzipCompression' => true,
        ]
    );

// Next, we can wrap up a new RandomNumberGenerator.
// We also pass in the $cache object we just created, and the desired cache expiry time in seconds.

$randomNumberGenerator = new CachingObjectWrapper(new RandomNumberGenerator(), $cache, 60 * 60);

// That's it!
// To test, we can tell the wrapped object to generate us two random numbers.

$randomNumber1 = $randomNumberGenerator->generate();
$randomNumber2 = $randomNumberGenerator->generate();

// Due to our caching, $randomNumber1 and $randomNumber2 should be identical.

The Versions

22/03 2018

dev-master

9999999-dev

Wraps up any PHP object so all its methods are cached.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

22/03 2018

dev-analysis-8A4vZy

dev-analysis-8A4vZy

Caching Object Wrapper

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

21/03 2018

v1.0.2

1.0.2.0

Caching Object Wrapper

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

21/03 2018

v1.0.1

1.0.1.0

Caching Object Wrapper

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

21/03 2018

v1.0.0

1.0.0.0

Caching Object Wrapper

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall