コード例 #1
0
ファイル: Cache.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * singleton function used to manage this object
  *
  * @param string  $host      the memcached server host
  * @param int     $port      the memcached server port
  * @param int     $timeout   the default timeout
  *
  * @return object
  * @static
  *
  */
 static function &singleton($host = 'localhost', $port = 11211, $timeout = 3600)
 {
     if (self::$_singleton === null) {
         if (defined('CIVICRM_USE_MEMCACHE') && CIVICRM_USE_MEMCACHE) {
             require_once 'CRM/Utils/Cache/Memcache.php';
             self::$_singleton = new CRM_Utils_Cache_Memcache($host, $port, $timeout);
         } else {
             self::$_singleton = new CRM_Utils_Cache();
         }
     }
     return self::$_singleton;
 }
コード例 #2
0
ファイル: CacheTest.php プロジェクト: kcristiano/civicrm-core
 public function testSetGetItem()
 {
     $originalValue = array('abc' => 'def');
     CRM_Core_BAO_Cache::setItem($originalValue, __CLASS__, 'testSetGetItem');
     $return_1 = CRM_Core_BAO_Cache::getItem(__CLASS__, 'testSetGetItem');
     $this->assertEquals($originalValue, $return_1);
     // Wipe out any in-memory copies of the cache. Check to see if the SQL
     // read is correct.
     CRM_Core_BAO_Cache::$_cache = NULL;
     CRM_Utils_Cache::$_singleton = NULL;
     $return_2 = CRM_Core_BAO_Cache::getItem(__CLASS__, 'testSetGetItem');
     $this->assertEquals($originalValue, $return_2);
 }
コード例 #3
0
ファイル: Cache.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Singleton function used to manage this object.
  *
  * @return CRM_Utils_Cache_Interface
  */
 public static function &singleton()
 {
     if (self::$_singleton === NULL) {
         $className = 'ArrayCache';
         // default to ArrayCache for now
         // Maintain backward compatibility for now.
         // Setting CIVICRM_USE_MEMCACHE or CIVICRM_USE_ARRAYCACHE will
         // override the CIVICRM_DB_CACHE_CLASS setting.
         // Going forward, CIVICRM_USE_xxxCACHE should be deprecated.
         if (defined('CIVICRM_USE_MEMCACHE') && CIVICRM_USE_MEMCACHE) {
             $className = 'Memcache';
         } elseif (defined('CIVICRM_USE_ARRAYCACHE') && CIVICRM_USE_ARRAYCACHE) {
             $className = 'ArrayCache';
         } elseif (defined('CIVICRM_DB_CACHE_CLASS') && CIVICRM_DB_CACHE_CLASS) {
             $className = CIVICRM_DB_CACHE_CLASS;
         }
         // a generic method for utilizing any of the available db caches.
         $dbCacheClass = 'CRM_Utils_Cache_' . $className;
         $settings = self::getCacheSettings($className);
         self::$_singleton = new $dbCacheClass($settings);
     }
     return self::$_singleton;
 }