0.9.1
0.9.1.0FSi Cache Component
The Requires
- php >=5.3.0
- fsi/reflection 0.9.*
by Norbert Orzechowicz
component cache fsi
0.9.0
0.9.0.0FSi Cache Component
The Requires
- php >=5.3.0
- fsi/reflection 0.9.*
by Norbert Orzechowicz
component cache fsi
Wallogit.com
2017 © Pedro Peláez
FSi Cache - Lightweight component that supports different cache storages with namespaces.
Do not use this package, as it will not receive any updates and may be deleted in the future., (*1)
Features:, (*2)
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)
We highly recommend to use autoloader generated by composer.phar., (*7)
Adding reflection into composer.json, (*8)
{
...
"require": {
...
"fsi/cache": "0.9.*"
...
},
...
}
Array cache should be used only in development environment to simulate normal cache behavior., (*9)
Example:, (*10)
<?php $cache = new ArrayCache();
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 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));
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.
FSi Cache Component
component cache fsi
FSi Cache Component
component cache fsi