2017 © Pedro Peláez
 

library cache

FSi Cache - Lightweight component that supports different cache storages with namespaces.

image

fsi/cache

FSi Cache - Lightweight component that supports different cache storages with namespaces.

  • Tuesday, June 20, 2017
  • by chives
  • Repository
  • 7 Watchers
  • 2 Stars
  • 109 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

THIS PACKAGE IS DEPRECATED

Do not use this package, as it will not receive any updates and may be deleted in the future., (*1)

FSi Cache Component Documentation

Features:, (*2)

  • supports array, APC and file cache storages. New storages will be added in the future.
  • supports namespaces inside of cache

By default all cache types use fsicache namespace, but you can change it using setNamespace method:, (*3)

<?php

$cache->setNamespace('namespace-name');

You can also use option 'namespace' while creating new cache (it can be used in all types of cache)., (*4)

<?php

$cache = new ArrayCache(array('namespace' => 'namespace-name'));

There is also a possibility to pass namespace as optional parameter into methods:, (*5)

  • getItem($key, $namespace = null)
  • hasItem($key, $namespace = null)
  • addItem($key, $item, $lifetime = 0, $namespace = null)
  • setItem($key, $item, $lifetime = 0, $namespace = null)
  • removeItem($key, $namespace = null)

If $namespace is null the current namespace is taken from method getNamespace()., (*6)

Setup and autoloading

We highly recommend to use autoloader generated by composer.phar., (*7)

Adding reflection into composer.json, (*8)

{
    ...
    "require": {
        ...
        "fsi/cache": "0.9.*"
        ...
    },
    ...
}

Array Cache

Array cache should be used only in development environment to simulate normal cache behavior., (*9)

Example:, (*10)

<?php

$cache = new ArrayCache();

APC Cache

APC cache require APC extension enabled in webserv. Informations about APC can be found at php.net, (*11)

Example:, (*12)

<?php

$cache = new ApcCache();

File Cache

File cache require cache directory path inside of variable $options['directory'] that is passed in constructor There is also an additional parameter $options['dirlvl'] that describe how deep cache should be nested. dirlvl parameter might be useful when you know that cache will hold a big amount of files. Higher dirlvl means less files in signle cache directory., (*13)

Example:, (*14)

<?php

$cache = new FileCache(array('directory' => '/tmp', 'dirlvl' => 3));

Examples

Basic Usage, (*15)

<?php

use FSi\Component\Cache\ApcCache;

// Create APC cache instance with default namespace.
$cache = new ApcCache();

// Check if there is a foo.
if ($cache->hasItem('foo')) {
    echo 'foo exists in cache!';
} else {
    // Store foo-value in cache under key foo for 3600 seconds.
    $cache->setItem('foo', 'foo-value', 3600);
}

Namespace Usage, (*16)

<?php

use FSi\Component\Cache\ApcCache;

// Create APC cache instance with default namespace.
$cache = new ApcCache();

$cache->setItem('key1', 'test', 0, 'testnamespace1');
$cache->setItem('key2', 'test', 0, 'testnamespace2');

$cache->hasItem('key1', 'testnamespace1'); // Will return true.
$cache->hasItem('key2', 'testnamespace2'); // Will return true.

$cache->hasItem('key2', 'testnamespace1'); // Will return false.
$cache->hasItem('key1', 'testnamespace2'); // Will return false.

The Versions

20/06 2017

dev-master

9999999-dev

FSi Cache - Lightweight component that supports different cache storages with namespaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Norbert Orzechowicz

component cache fsi

08/11 2012

0.9.3

0.9.3.0

FSi Cache - Lightweight component that supports different cache storages with namespaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Norbert Orzechowicz

component cache fsi

19/09 2012

0.9.2

0.9.2.0

FSi Cache Component

  Sources   Download

The Requires

  • php >=5.3.0

 

by Norbert Orzechowicz

component cache fsi

10/07 2012

0.9.1

0.9.1.0

FSi Cache Component

  Sources   Download

The Requires

 

by Norbert Orzechowicz

component cache fsi

09/07 2012

0.9.0

0.9.0.0

FSi Cache Component

  Sources   Download

The Requires

 

by Norbert Orzechowicz

component cache fsi