# sfCacheBackportPlugin This plugin has currently many different usages: * Provides Symfony 1.1+ cache classes for Symfony 1.0 (with an adapter for view caching). * Also provides a transparent and extensible API to cache objects with the cache classes, for any version of Symfony. * A convenient way to get cache classes depending on your environment. ## Using the classes It's the same as using the classes from Symfony 1.1+ except that you add ``Backport`` at the end of the class name. One nice addition is the ``sfNoCacheBackport`` class; especially if you use it with ``sfSpawnCache``. ## Using sfSpawnCache It's fairly common to have many different environments, with different caches available. You also might want to avoid to render your production website unusable if, say, your Memcache server goes down. Enter sfSpawnCache! Usage: ``sfSpawnCache::get($classes, $options, $reuse)`` Example: ``sfSpawnCache::get(array('sfPenguinCache', 'sfXCacheCache', 'sfNoCache'), array('penguins'=>'plenty'))`` For more information, read the associated PHPDoc. ## Caching views in Symfony 1.0 with the backported classes Example config (``factories.yml``): view_cache: class: sfCacheBackportAdapter param: classes: [ sfXCacheCacheBackport, sfFileCacheBackport, sfNoCacheBackport] options: automatic_cleaning_factor: 0 cache_dir: %SF_TEMPLATE_CACHE_DIR% prefix: myapp_viewcache This will try to use ``sfXCacheCacheBackport``, then ``sfFileCacheBackport`` if it fails, then ``sfNoCacheBackport``. The cache should be enabled in your settings.yml by the way. ## Object Caching As an added bonus the classes ship with functions to store and retrieve objects from the cache. The point is to be able to store objects without worrying about the cache capabilities (for instance Memcache handles serialization for you, the others don't). They behave exactly like set() et get() are respectively are setObject() and getObject(). ## I want to use the object caching with Symfony 1.1+ Create a ``sfCacheBackport.class.php`` in your lib/ folder with the following content: class sfCacheBackport extends sfCache {} And done. ## What is this callable thing I saw in the code? Is it working? I don't know (yet).