PHP code example of epwt / cache-bundle

1. Go to this page and download the library: Download epwt/cache-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

epwt / cache-bundle example snippets


public function registerBundles()
{
	$bundles[] = new EPWT\CacheBundle\EPWTCacheBundle();
}

class HelloWorldCommand extends ContainerAwareCommand
{
    use CacheItemPoolsAwareTrait;

    protected function configure()
    {
        $this->setName('acme:hello');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $pool = $this->getCacheItemPool('acme_demo_pool');

        $poolItem = new CacheItem('foo');
        $poolItem->set('bar');

        $pool->save($poolItem);
    }
}

class HelloWorldCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this->setName('acme:hello');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $pool = $this->getContainer()->get('epwt_cache_pools')->get('acme_demo_pool');

        $poolItem = new CacheItem('foo');
        $poolItem->set('bar');

        $pool->save($poolItem);
    }
}

xml
<service id="acme.demo.items.pool" class="stdClass">
    <tag name="epwt_cache_pool" alias="acme_demo_pool" driver="redis" redis-id="acme.demo.redis"/>
</service>
xml
<service id="acme.demo.items.pool" class="stdClass">
    <tag name="epwt_cache_pool" alias="acme_demo_pool" driver="snc_redis" sncredis-client="default"/>
</service>