Developers

License

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.

Release 1.0.0 - 16/04/2009

sfCacheBackportPlugin

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!

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?

Before caching

Example:

sfMixer::register('MyClass:cache:set', array('MyClass', 'cacheSet'));

The function can alter the object, and if we return an object,
the cache will use it instead (only useful if you clone it).

The debug features

If both sfConfig options sf_debug and sf_logging_enabled are enabled,
sfSpawnCache will automatically encapsulate the spawned cache object with
sfDebugCacheBackport. This class will forward all methods to the real cache
object and log the calls.
If you want to use it manually, just use:

$debug_cache = new sfDebugCacheBackport($real_cache);

If app_cache_backport_log_to_db is enabled (the default), the cache actions
will be logged to the Database tab of the DebugBar.
In all cases, the ObjectCache timer will have the total number of calls to and
the time spent into setObject() and getObject().