zendCachePlugin
1.0.0stable
for sf 1.2 MIT
The zendCachePlugin implements Zend caching system in your Symfony applications.
Zend Caching system is availableif your server is running on Zend Platform or Zend Server.
It provide to classes that extends sfCache :
* zendDiskCache for disk cache system
* zendShmCache for shared memory cache system
Developers
License
Copyright (c) 2009 Julien Garand
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Releases for sf 1.2
| Version |
License |
API |
Released |
|
1.0.0stable
|
MIT |
1.0.0stable
|
27/02/2009 |
Changelog for release 1.0.0 - 27/02/2009
Other releases
Release 1.0.0 - 27/02/2009
zendCachePlugin
The zendCachePlugin implements Zend caching system in your Symfony applications.
Zend Caching system is availableif your server is running on Zend Platform or Zend Server.
It provide to classes that extends sfCache :
* zendDiskCache for disk cache system
* zendShmCache for shared memory cache system
Installation
Install the plugin
$ symfony plugin:install zendCachePlugin
Enable the plugin in your ProjectConfiguration class
# in file SF_ROOT_DIR/config/Projectconfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
/* ... */
$this->enablePlugins( 'zendCachePlugin' );
/* ... */
}
}
Clear the cache
$ symfony cc
Usage
View and partial caching
To use Zend Data cache for caching your views and partials, update apps/my_app/config/factories.yml :
all:
view_cache:
class: zendShmCache # or "zendDiskCache"
param:
automaticCleaningFactor: 0
Clear cache and you are done !
$ symfony cc
Use it in scripts
There is nothing more in it than in the sfCache API:
<?php
// instanciate a $cache object
$cache = new zendShmCache();
// Storing data in cache
$cache->set( 'a key', $my_data, $user_defined_lifetime );
// Checking if some data is available in cache
if ( $cache->has('some data') )
{
// It's here ! let's retrieve it
$data = $cache->get('some data');
}
else
{
// Do not exists or to late (timed out...)
}
// removing some data
$cache->remove( 'some data');
// cleaning the full cache
$cache->clean();
?>
Using namespaces
Namespaces use the prefix option:
<?php
// instanciate to cache objects with different namespaces
$cache_DE = new zendShmCache( array( 'prefix' => 'de' ) );
$cache_FR = new zendShmCache( array( 'prefix' => 'en' ) );
// store datas
$cache_DE->set( 'hello', 'Guten Tag' );
$cache_FR->set( 'hello', 'Bonjour' );
// and retrieve them
echo $cache_DE->get( 'hello' ); // 'Guten Tag';
echo $cache_FR->get( 'hello' ); // 'Bonjour';
?>
TODO
- Checking if
prefix options is well formed (zend_cache_info is not allowed !!!, avoid :: in prefix name)
- Using an alternate
namespace option