[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/cache/ -> cachemanager.class.php (source)

   1  <?php
   2      
   3     /**
   4      * \ingroup Cache
   5      *
   6      * Provides a singleton for storing and retrieving data from a global cache. You probably
   7      * want to use the getCache() method in this class instead of creating objects of the Cache
   8      * class.
   9      *
  10      * @see Cache
  11      */
  12      class CacheManager 
  13      {
  14          /**
  15           * Returns an instance of the cache.
  16           *
  17           * @param cacheEnabled Set this to false if you wish this class to always return no data,
  18           * meaning that it will have to be loaded every time.
  19           * @return The current global instance of the Lite class
  20           */
  21          function &getCache( $cacheEnabled = true )
  22          {
  23              static $cache;
  24  
  25              if( $cache == null ) {
  26                  // source the neccessary files
  27                  lt_include( PLOG_CLASS_PATH . "class/config/configfilestorage.class.php" );
  28  
  29                  $config = new ConfigFileStorage( Array( "file" => PLOG_CLASS_PATH."config/cache.properties.php" ));
  30                  
  31                  if( $config->getValue( 'cache_method' ) == 'memcached' ) {
  32                      lt_include( PLOG_CLASS_PATH . "class/cache/memcache.class.php" );
  33                      // define defaults
  34                      $cacheParameter = array(
  35                          'servers' => $config->getValue( 'memcached_servers' ),
  36                          'life_time' => $config->getValue( 'memcached_life_time' ),
  37                          'debug' => $config->getValue( 'memcached_debug' ),
  38                          'compress_threshold' => $config->getValue( 'memcached_compress_threshold' ),
  39                          'persistant' => $config->getValue( 'memcached_persistant' ),
  40                      );
  41                      
  42                      // build a new cache object
  43                      $cache = new MemCache( $cacheParameter);
  44                  }
  45                  else {                    
  46                      lt_include( PLOG_CLASS_PATH . "class/cache/cache.class.php" );                    
  47                      // configure the Cache_Lite parameters, but providing some defaults in case the config file isn't there
  48                      $cacheParameter = array(
  49                          'cacheDir' => $config->getValue( 'cache_lite_cache_dir', "./tmp/" ),
  50                          'lifeTime' => $config->getValue( 'cache_lite_life_time', 604800 ),
  51                          'readControl' => $config->getValue( 'cache_lite_read_control', false ),
  52                          'automaticSerialization' => $config->getValue( 'cache_lite_automatic_serialization', true ),
  53                          'hashedDirectoryLevel' => $config->getValue( 'cache_lite_hashed_directory_level', 2 ),
  54                          'caching' => $cacheEnabled
  55                      );
  56  
  57                      // build a new cache object
  58                      $cache = new Cache( $cacheParameter);
  59                  }
  60              }
  61              return $cache;
  62          }
  63      }
  64  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics