2017 © Pedro Peláez
 

joomla-package cache

Joomla Cache Package

image

joomla/cache

Joomla Cache Package

  • Friday, May 25, 2018
  • by mbabker
  • Repository
  • 8 Watchers
  • 3 Stars
  • 14,445 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 14 Versions
  • 5 % Grown

The README.md

The Cache Package Build Status

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

This cache package is based on a version of the now accepted PSR-6 as it was in 2013., (*2)

Deprecated

The joomla/cache package has been deprecated with no further updates planned., (*3)

Options and General Usage

Following option as available across a cache storage types:, (*4)

  • ttl - Time to live.
use Joomla\Cache;

$options = array(
    'ttl' => 900,
);

$cache = new Cache\Runtime($options);

// Set a value in the cache.
$cache->set('key', 'value');

// Get the value back.
$value = $cache->get('key')->getValue();

// Remove the item from the cache.
$cache->remove('key');

// Clear all the items from the cache.
$cache->clear();

// Get multiple values from the cache at once.
$values = $cache->getMultiple(array('key1', 'key2'));

// Set multiple values from the cache at once.
$values = $cache->setMultiple(array('key1' => 'value1', 'key2' => 'value2'));

// Remove multiple values from the cache at once.
$values = $cache->removeMultiple(array('key1', 'key2'));

Cache Storage Types

The following storage types are supported., (*5)

Apc

use Joomla\Cache;

$cache = new Cache\Apc;

File

The File cache allows the following additional options:, (*6)

  • file.path - the path where the cache files are to be stored.
  • file.locking
use Joomla\Cache;

$options = array(
    'file.path' => __DIR__ . '/cache',
);

$cache = new Cache\File($options);

Memcached

use Joomla\Cache;

$cache = new Cache\Memcached;

None

use Joomla\Cache;

$cache = new Cache\None;

Runtime

use Joomla\Cache;

$cache = new Cache\Runtime;

Wincache

use Joomla\Cache;

$cache = new Cache\Wincache;

XCache

use Joomla\Cache;

$cache = new Cache\XCache;

Test Mocking

The Cache package provide a PHPUnit helper to mock a Cache\Cache object or an Cache\Item object. You can include your own optional overrides in the test class for the following methods:, (*7)

  • Cache\Cache::get: Add a method called mockCacheGet to your test class. If omitted, the helper will return a default mock for the Cache\Item class.
  • Cache\Item::getValue: Add a method called mockCacheItemGetValue to your test class. If omitted, the mock Cache\Item will return "value" when this method is called.
  • Cache\Item::isHit: Add a method called mockCacheItemIsHit to your test class. If omitted, the mock Cache\Item will return false when this method is called.
use Joomla\Cache\Tests\Mocker as CacheMocker;

class FactoryTest extends \PHPUnit_Framework_TestCase
{
    private $instance;

    //
    // The following mocking methods are optional.
    //

    /**
     * Callback to mock the Cache\Item::getValue method.
     *
     * @return  string
     */
    public function mockCacheItemGetValue()
    {
        // This is the default handling.
        // You can override this method to provide a custom return value.
        return 'value';
    }

    /**
     * Callback to mock the Cache\Item::isHit method.
     *
     * @return  boolean
     */
    public function mockCacheItemIsHit()
    {
        // This is the default handling.
        // You can override this method to provide a custom return value.
        return false;
    }

    /**
     * Callback to mock the Cache\Cache::get method.
     *
     * @param   string  $text  The input text.
     *
     * @return  string
     */
    public function mockCacheGet($key)
    {
        // This is the default handling.
        // You can override this method to provide a custom return value.
        return $this->createMockItem();
    }

    protected function setUp()
    {
        parent::setUp();

        $mocker = new CacheMocker($this);

        $this->instance = new SomeClass($mocker->createMockCache());
    }
}

Installation via Composer

Add "joomla/cache": "~1.0" to the require block in your composer.json and then run composer install., (*8)

{
    "require": {
        "joomla/cache": "~1.0"
    }
}

Alternatively, you can simply run the following from the command line:, (*9)

composer require joomla/cache "~1.0"

If you want to include the test sources, use, (*10)

composer require --prefer-source joomla/cache "~1.0"

The Versions

25/05 2018

dev-2.0-dev

dev-2.0-dev https://github.com/joomla-framework/cache

Joomla Cache Package

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

 

The Development Requires

framework cache joomla

25/05 2018

dev-master

9999999-dev https://github.com/joomla-framework/cache

Joomla Cache Package

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

  • php ^5.3.10|~7.0

 

The Development Requires

framework cache joomla

25/05 2018

1.2.0

1.2.0.0 https://github.com/joomla-framework/cache

Joomla Cache Package

  Sources   Download

GPL-2.0-or-later

The Requires

  • php ^5.3.10|~7.0

 

The Development Requires

framework cache joomla

10/12 2016

1.1.5

1.1.5.0 https://github.com/joomla-framework/cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php ^5.3.10|~7.0

 

The Development Requires

framework cache joomla

24/02 2015

1.1.4

1.1.4.0 https://github.com/joomla-framework/cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

23/08 2014

1.1.3

1.1.3.0 https://github.com/joomla-framework/cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

10/02 2014

1.1.2

1.1.2.0 https://github.com/joomla-framework/cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

09/02 2014

1.1.1

1.1.1.0 https://github.com/joomla-framework/cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

16/01 2014

1.1.0

1.1.0.0 https://github.com/joomla/joomla-framework-cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

05/11 2013

1.0

1.0.0.0 https://github.com/joomla/joomla-framework-cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

22/10 2013

1.0-beta3

1.0.0.0-beta3 https://github.com/joomla/joomla-framework-cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

16/08 2013

1.0-beta2

1.0.0.0-beta2 https://github.com/joomla/joomla-framework-cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

16/08 2013

1.0-beta

1.0.0.0-beta https://github.com/joomla/joomla-framework-cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla

04/06 2013

1.0-alpha

1.0.0.0-alpha https://github.com/joomla/joomla-framework-cache

Joomla Cache Package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework cache joomla