snowcap / cache-bundle
Symfony SnowcapCacheBundle
Installs: 577
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- symfony/framework-bundle: >=2.2
This package is not auto-updated.
Last update: 2024-12-21 14:48:01 UTC
README
This bundle is used to provide access to cache drivers.
This is a work in progress with two drivers: Memcached and APC.
Installation
-
Add this bundle to your
vendor/
dir:Add the following line in your
composer.json
file:"snowcap/cache-bundle": "dev-master",
Run composer:
composer update snowcap/cache-bundle
-
Add this bundle to your application's kernel:
// app/ApplicationKernel.php public function registerBundles() { return array( // ... new Snowcap\CacheBundle\SnowcapCacheBundle(), // ... ); }
-
Add the configuration in your config.yml file
snowcap_cache: namespace: yournamspace caches: tweets: type: memcached options: server: localhost port: 11211 ttl: 86400 flickr: type: memcached options: server: localhost port: 11211 ttl: 45632
Usage
$cacheManager = $this->get('snowcap_cache.manager');
$cache = $cacheManager->getCache('tweets');
if ($cache->isEnabled()) {
if (false === $tweets = $cache->get('tweets')) {
$tweets = $this->getTweets();
$cache->set('tweets', $tweets);
}
} else {
$tweets = $this->getTweets();
}
Running the tests
Before running the tests, you will need to install the bundle dependencies. Do it using composer :
curl -s http://getcomposer.org/installer | php
php composer.phar --dev install
Then you can simply launch phpunit
phpunit