当前位置: 首页>>代码示例>>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;未经允许,请勿转载。