cacheSettings.php

System-wide access to selected CachePeer and DaoWorker.
See also:
CachePeer

http://onphp.org/examples.Cache.en.html

<?php
    // $Id: cacheSettings.php 4687 2007-12-09 18:57:18Z voxus $

    require dirname(__FILE__).'/../../global.inc.php.tpl';

    // set up default cache peer

    Cache::setPeer(
        new ReferencePool(
            Memcached::create()
        )
    );

    // or even several aggregated peers
    
    Cache::setPeer(
        new ReferencePool(
            AggregateCache::create()->
            addPeer(
                'memcached daemon at localhost',
                Memcached::create()
            )->
            addPeer(
                'local low-priority file system',
                RubberFileSystem::create('/tmp/onphp-cache'),
                AggregateCache::LEVEL_VERYLOW
            )
        )
    );

    // let's test out cache system

    $ts = new Timestamp(time());

    $key = 'timestamp_object';

    if (Cache::me()->set($key, $ts, 2)) {
        echo "object is in cache now\n";

        if ($cached = Cache::me()->get($key)) {
            echo "got from cache:\n";
            print_r($cached);
        }

    } else {
        echo "failed to store object in cache\n";
    }
?>

Generated on Sun Dec 9 21:56:22 2007 for onPHP by  doxygen 1.5.4