2017 © Pedro Peláez
 

symfony-bundle filesystem-cache-bundle

Adds a filesystem cache option

image

ctors/filesystem-cache-bundle

Adds a filesystem cache option

  • Saturday, October 5, 2013
  • by tvlooy
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Filesystem cache - Symfony 2 Bundle

This is a Symfony 2 Bundle that adds a filesystem cache., (*1)

Installing via Composer

{
    "require": {
        "ctors/filesystem-cache-bundle": "dev-master"
    }
}

Using and Setting Up

AppKernel.php

public function registerBundles() {
    $bundles = array(
        new Ctors\FilesystemCacheBundle\CtorsFilesystemCacheBundle(),
    );
}

Service usage

The cache service's name is ctors.cache. You can alias it in your project's config.yml:, (*2)

service:
    cache:
        alias: ctors.cache

The cache implements the Doctrine CacheProvider interface. Simple usage example:, (*3)

/** @var \Doctrine\Common\Cache\CacheProvider $cache */
$cache = $this->get('cache');

if ($cache->contains($searchKey)) {
    $value = unserialize($cache->fetch($searchKey));
} else {
    $value = new SomeValue();
    $cache->save($searchKey, serialize($value));
}

Command usage

There is a command that prints the cache usage:, (*4)

$ app/console ctors:filesystemcache:stats 
Filesystem cache statistics (05/10/2013 15:07:09)
  - number of objects 3
  - disk usage 28K

You can also watch the cache, it will update any time a resource is added or removed:, (*5)

$ app/console ctors:filesystemcache:stats -w
Filesystem cache statistics (05/10/2013 15:07:11)
  - number of objects 3
  - disk usage 28K
Filesystem cache statistics (05/10/2013 15:07:18)
  - number of objects 4
  - disk usage 44K
Filesystem cache statistics (05/10/2013 15:07:22)
  - number of objects 5
  - disk usage 48K

Notes

I added a CacheWarmer and CacheClearer listener. At the moment they just make sure the cache directory exists (warmer) and is removed (clearer). You could extend these to for example mount a tmpfs on the cache directory. It's just an idea., (*6)

The Versions

05/10 2013

dev-master

9999999-dev https://github.com/tvlooy/CtorsFilesystemCacheBundle

Adds a filesystem cache option

  Sources   Download

ISC

The Requires

 

by Tom Van Looy

filesystem cache bundle

05/10 2013

1.0.0

1.0.0.0 https://github.com/tvlooy/CtorsFilesystemCacheBundle

Adds a filesystem cache option

  Sources   Download

ISC

The Requires

 

by Tom Van Looy

filesystem cache bundle