當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Utils_Cache類代碼示例

本文整理匯總了PHP中CRM_Utils_Cache的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_Cache類的具體用法?PHP CRM_Utils_Cache怎麽用?PHP CRM_Utils_Cache使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CRM_Utils_Cache類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: tearDown

 public function tearDown()
 {
     global $civicrm_setting;
     $civicrm_setting = $this->origSetting;
     CRM_Utils_Cache::singleton()->flush();
     parent::tearDown();
 }
開發者ID:hyebahi,項目名稱:civicrm-core,代碼行數:7,代碼來源:SettingTest.php

示例2: create

 /**
  * Create civicrm settings. This is the same as add but it clears the cache and
  * reloads the config object
  *
  * @param array $params
  *   Associated array of civicrm variables.
  *
  * @return void
  */
 public static function create($params)
 {
     self::add($params);
     $cache = CRM_Utils_Cache::singleton();
     $cache->delete('CRM_Core_Config');
     $cache->delete('CRM_Core_Config' . CRM_Core_Config::domainID());
     $config = CRM_Core_Config::singleton(TRUE, TRUE);
 }
開發者ID:riyadennis,項目名稱:my_civicrm,代碼行數:17,代碼來源:ConfigSetting.php

示例3: singleton

 /**
  * @param bool $fresh
  * @return CRM_Cxn_CiviCxnHttp
  */
 public static function singleton($fresh = FALSE)
 {
     if (self::$singleton === NULL || $fresh) {
         $cache = CRM_Utils_Cache::create(array('name' => 'CiviCxnHttp', 'type' => Civi::settings()->get('debug_enabled') ? 'ArrayCache' : array('SqlGroup', 'ArrayCache'), 'prefetch' => FALSE));
         self::$singleton = new CRM_Cxn_CiviCxnHttp($cache);
     }
     return self::$singleton;
 }
開發者ID:FundingWorks,項目名稱:civicrm-core,代碼行數:12,代碼來源:CiviCxnHttp.php

示例4: setCache

 static function setCache($values, $group, $componentID = NULL, $contactID = NULL)
 {
     if (!isset(self::$_cache)) {
         self::$_cache = array();
     }
     $cacheKey = "CRM_Setting_{$group}_{$componentID}_{$contactID}";
     self::$_cache[$cacheKey] = $values;
     $globalCache = CRM_Utils_Cache::singleton();
     $result = $globalCache->set($cacheKey, $values);
     return $cacheKey;
 }
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:11,代碼來源:Setting.php

示例5: CRM_Utils_Cache_Memcache

 /**
  * 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;
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:23,代碼來源:Cache.php

示例6: testSetGetItem

 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);
 }
開發者ID:kcristiano,項目名稱:civicrm-core,代碼行數:13,代碼來源:CacheTest.php

示例7: getPetitionActivityType

 /**
  * Find the activity type ID for petitions.
  *
  * @return int
  *   The activity type ID.
  */
 public static function getPetitionActivityType()
 {
     $cache = CRM_Utils_Cache::singleton();
     $petitionActivityType = $cache->get('petitionemail_petitionActivityType');
     if (empty($petitionActivityType)) {
         try {
             $petitionTypeParams = array('name' => "activity_type", 'api.OptionValue.getsingle' => array('option_group_id' => '$value.id', 'name' => "Petition", 'options' => array('limit' => 1)), 'options' => array('limit' => 1));
             $petitionTypeInfo = civicrm_api3('OptionGroup', 'getsingle', $petitionTypeParams);
         } catch (CiviCRM_API3_Exception $e) {
             $error = $e->getMessage();
             CRM_Core_Error::debug_log_message(t('API Error: %1', array(1 => $error, 'domain' => 'com.aghstrategies.petitionemail')));
         }
         if (empty($petitionTypeInfo['api.OptionValue.getsingle']['value'])) {
             return;
         } else {
             $petitionActivityType = $petitionTypeInfo['api.OptionValue.getsingle']['value'];
             $cache->set('petitionemail_petitionActivityType', $petitionActivityType);
         }
     }
     return $petitionActivityType;
 }
開發者ID:aghstrategies,項目名稱:com.aghstrategies.petitionemail,代碼行數:27,代碼來源:Utils.php

示例8: elseif

 /**
  * 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;
 }
開發者ID:FundingWorks,項目名稱:civicrm-core,代碼行數:28,代碼來源:Cache.php

示例9: populate

 /**
  * DEPRECATED generic populate method
  * All pseudoconstant functions that use this method are also deprecated.
  *
  * The static array $var is populated from the db
  * using the <b>$name DAO</b>.
  *
  * Note: any database errors will be trapped by the DAO.
  *
  * @param array   $var        the associative array we will fill
  * @param string  $name       the name of the DAO
  * @param boolean $all        get all objects. default is to get only active ones.
  * @param string  $retrieve   the field that we are interested in (normally name, differs in some objects)
  * @param string  $filter     the field that we want to filter the result set with
  * @param string  $condition  the condition that gets passed to the final query as the WHERE clause
  *
  * @return void
  * @access public
  * @static
  */
 public static function populate(&$var, $name, $all = FALSE, $retrieve = 'name', $filter = 'is_active', $condition = NULL, $orderby = NULL, $key = 'id', $force = NULL)
 {
     $cacheKey = "CRM_PC_{$name}_{$all}_{$key}_{$retrieve}_{$filter}_{$condition}_{$orderby}";
     $cache = CRM_Utils_Cache::singleton();
     $var = $cache->get($cacheKey);
     if ($var && empty($force)) {
         return $var;
     }
     $object = new $name();
     $object->selectAdd();
     $object->selectAdd("{$key}, {$retrieve}");
     if ($condition) {
         $object->whereAdd($condition);
     }
     if (!$orderby) {
         $object->orderBy($retrieve);
     } else {
         $object->orderBy($orderby);
     }
     if (!$all) {
         $object->{$filter} = 1;
     }
     $object->find();
     $var = array();
     while ($object->fetch()) {
         $var[$object->{$key}] = $object->{$retrieve};
     }
     $cache->set($cacheKey, $var);
 }
開發者ID:TheCraftyCanvas,項目名稱:aegir-platforms,代碼行數:49,代碼來源:PseudoConstant.php

示例10: getTableColumnGroup

 /**
  * Get the database table name and column name for a custom field.
  *
  * @param int $fieldID
  *   The fieldID of the custom field.
  * @param bool $force
  *   Force the sql to be run again (primarily used for tests).
  *
  * @return array
  *   fatal is fieldID does not exists, else array of tableName, columnName
  */
 public static function getTableColumnGroup($fieldID, $force = FALSE)
 {
     $cacheKey = "CRM_Core_DAO_CustomField_CustomGroup_TableColumn_{$fieldID}";
     $cache = CRM_Utils_Cache::singleton();
     $fieldValues = $cache->get($cacheKey);
     if (empty($fieldValues) || $force) {
         $query = "\nSELECT cg.table_name, cf.column_name, cg.id\nFROM   civicrm_custom_group cg,\n       civicrm_custom_field cf\nWHERE  cf.custom_group_id = cg.id\nAND    cf.id = %1";
         $params = array(1 => array($fieldID, 'Integer'));
         $dao = CRM_Core_DAO::executeQuery($query, $params);
         if (!$dao->fetch()) {
             CRM_Core_Error::fatal();
         }
         $dao->free();
         $fieldValues = array($dao->table_name, $dao->column_name, $dao->id);
         $cache->set($cacheKey, $fieldValues);
     }
     return $fieldValues;
 }
開發者ID:Hack4Eugene,項目名稱:Hack4Cause2016,代碼行數:29,代碼來源:CustomField.php

示例11: getDefaultFromAddress

 /**
  * Find the site's default "from" address.
  *
  * @return string
  *   The default "from" name and address.
  */
 public function getDefaultFromAddress()
 {
     if (empty($this->defaultFromAddress)) {
         $cache = CRM_Utils_Cache::singleton();
         $this->defaultFromAddress = $cache->get('petitionemail_defaultFromAddress');
     }
     if (empty($this->defaultFromAddress)) {
         try {
             $defaultMailParams = array('name' => "from_email_address", 'options' => array('limit' => 1), 'api.OptionValue.getsingle' => array('is_default' => 1, 'options' => array('limit' => 1)));
             $defaultMail = civicrm_api3('OptionGroup', 'getsingle', $defaultMailParams);
             if (empty($defaultMail['api.OptionValue.getsingle']['label']) || $defaultMail['api.OptionValue.getsingle']['label'] == $defaultMail['api.OptionValue.getsingle']['name']) {
                 // No site email.
                 // TODO: leave some kind of message with explanation.
                 return NULL;
             }
             $this->defaultFromAddress = $defaultMail['api.OptionValue.getsingle']['label'];
             $cache->set('petitionemail_defaultFromAddress', $this->defaultFromAddress);
         } catch (CiviCRM_API3_Exception $e) {
             $error = $e->getMessage();
             CRM_Core_Error::debug_log_message(t('API Error: %1', array(1 => $error, 'domain' => 'com.aghstrategies.petitionemail')));
         }
     }
     return $this->defaultFromAddress;
 }
開發者ID:aghstrategies,項目名稱:com.aghstrategies.petitionemail,代碼行數:30,代碼來源:Interface.php

示例12: populate

 /**
  * populate the object from the database. generic populate
  * method
  *
  * The static array $var is populated from the db
  * using the <b>$name DAO</b>. 
  *
  * Note: any database errors will be trapped by the DAO.
  *
  * @param array   $var        the associative array we will fill
  * @param string  $name       the name of the DAO
  * @param boolean $all        get all objects. default is to get only active ones.
  * @param string  $retrieve   the field that we are interested in (normally name, differs in some objects)
  * @param string  $filter     the field that we want to filter the result set with
  * @param string  $condition  the condition that gets passed to the final query as the WHERE clause
  *
  * @return void
  * @access public
  * @static
  */
 public static function populate(&$var, $name, $all = false, $retrieve = 'name', $filter = 'is_active', $condition = null, $orderby = null, $key = 'id')
 {
     $cacheKey = "CRM_PC_{$name}_{$all}_{$key}_{$retrieve}_{$filter}_{$condition}_{$orderby}";
     $cache =& CRM_Utils_Cache::singleton();
     $var = $cache->get($cacheKey);
     if ($var) {
         return $var;
     }
     require_once str_replace('_', DIRECTORY_SEPARATOR, $name) . ".php";
     eval('$object = new ' . $name . '( );');
     $object->selectAdd();
     $object->selectAdd("{$key}, {$retrieve}");
     if ($condition) {
         $object->whereAdd($condition);
     }
     if (!$orderby) {
         $object->orderBy($retrieve);
     } else {
         $object->orderBy($orderby);
     }
     if (!$all) {
         $object->{$filter} = 1;
     }
     $object->find();
     $var = array();
     while ($object->fetch()) {
         $var[$object->{$key}] = $object->{$retrieve};
     }
     $cache->set($cacheKey, $var);
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:50,代碼來源:PseudoConstant.php

示例13: group

 /**
  * @param $type
  * @param null $contactID
  * @param string $tableName
  * @param null $allGroups
  * @param null $includedGroups
  *
  * @return array
  */
 public static function group($type, $contactID = NULL, $tableName = 'civicrm_saved_search', $allGroups = NULL, $includedGroups = NULL)
 {
     $acls = CRM_ACL_BAO_Cache::build($contactID);
     $ids = array();
     if (!empty($acls)) {
         $aclKeys = array_keys($acls);
         $aclKeys = implode(',', $aclKeys);
         $cacheKey = "{$tableName}-{$aclKeys}";
         $cache = CRM_Utils_Cache::singleton();
         $ids = $cache->get($cacheKey);
         if (!$ids) {
             $query = "\nSELECT   a.operation, a.object_id\n  FROM   civicrm_acl_cache c, civicrm_acl a\n WHERE   c.acl_id       =  a.id\n   AND   a.is_active    =  1\n   AND   a.object_table = %1\n   AND   a.id        IN ( {$aclKeys} )\nGROUP BY a.operation,a.object_id\nORDER BY a.object_id\n";
             $params = array(1 => array($tableName, 'String'));
             $dao = CRM_Core_DAO::executeQuery($query, $params);
             while ($dao->fetch()) {
                 if ($dao->object_id) {
                     if (self::matchType($type, $dao->operation)) {
                         $ids[] = $dao->object_id;
                     }
                 } else {
                     // this user has got the permission for all objects of this type
                     // check if the type matches
                     if (self::matchType($type, $dao->operation)) {
                         foreach ($allGroups as $id => $dontCare) {
                             $ids[] = $id;
                         }
                     }
                     break;
                 }
             }
             $cache->set($cacheKey, $ids);
         }
     }
     if (empty($ids) && !empty($includedGroups) && is_array($includedGroups)) {
         $ids = $includedGroups;
     }
     CRM_Utils_Hook::aclGroup($type, $contactID, $tableName, $allGroups, $ids);
     return $ids;
 }
開發者ID:prashantgajare,項目名稱:civicrm-core,代碼行數:48,代碼來源:ACL.php

示例14: getOptionValuesArray

 /**
  * Get the values of all option values given an option group ID. Store in system cache
  * Does not take any filtering arguments. The object is to avoid hitting the DB and retrieve
  * from memory
  *
  * @param int $optionGroupID
  *   The option group for which we want the values from.
  *
  * @return array
  *   an array of array of values for this option group
  */
 public static function getOptionValuesArray($optionGroupID)
 {
     // check if we can get the field values from the system cache
     $cacheKey = "CRM_Core_BAO_OptionValue_OptionGroupID_{$optionGroupID}";
     $cache = CRM_Utils_Cache::singleton();
     $optionValues = $cache->get($cacheKey);
     if (empty($optionValues)) {
         $dao = new CRM_Core_DAO_OptionValue();
         $dao->option_group_id = $optionGroupID;
         $dao->orderBy('weight ASC, label ASC');
         $dao->find();
         $optionValues = array();
         while ($dao->fetch()) {
             $optionValues[$dao->id] = array();
             CRM_Core_DAO::storeValues($dao, $optionValues[$dao->id]);
         }
         $cache->set($cacheKey, $optionValues);
     }
     return $optionValues;
 }
開發者ID:kidaa30,項目名稱:yes,代碼行數:31,代碼來源:OptionValue.php

示例15: commonProcess

 public function commonProcess(&$params)
 {
     require_once "CRM/Core/BAO/Setting.php";
     CRM_Core_BAO_Setting::add($params);
     // also delete the CRM_Core_Config key from the database
     $cache =& CRM_Utils_Cache::singleton();
     $cache->delete('CRM_Core_Config');
     // save autocomplete search options
     if (CRM_Utils_Array::value('autocompleteContactSearch', $params)) {
         $config =& new CRM_Core_DAO_Preferences();
         $config->domain_id = CRM_Core_Config::domainID();
         $config->find(true);
         $config->contact_autocomplete_options = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
         $config->save();
     }
     CRM_Core_Session::setStatus(ts('Your changes have been saved.'));
 }
開發者ID:ksecor,項目名稱:civicrm,代碼行數:17,代碼來源:Setting.php


注:本文中的CRM_Utils_Cache類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。