当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_BAO_Cache::_cache方法代码示例

本文整理汇总了PHP中CRM_Core_BAO_Cache::_cache方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Cache::_cache方法的具体用法?PHP CRM_Core_BAO_Cache::_cache怎么用?PHP CRM_Core_BAO_Cache::_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_BAO_Cache的用法示例。


在下文中一共展示了CRM_Core_BAO_Cache::_cache方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: flushCache

 /**
  * Reset the various system caches and some important static variables.
  */
 public static function flushCache()
 {
     // flush out all cache entries so we can reload new data
     // a bit aggressive, but livable for now
     $cache = CRM_Utils_Cache::singleton();
     $cache->flush();
     // also reset the various static memory caches
     // reset the memory or array cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields', NULL, FALSE);
     // reset ACL cache
     CRM_ACL_BAO_Cache::resetCache();
     // reset various static arrays used here
     CRM_Contact_BAO_Contact::$_importableFields = CRM_Contact_BAO_Contact::$_exportableFields = CRM_Contribute_BAO_Contribution::$_importableFields = CRM_Contribute_BAO_Contribution::$_exportableFields = CRM_Pledge_BAO_Pledge::$_exportableFields = CRM_Contribute_BAO_Query::$_contributionFields = CRM_Core_BAO_CustomField::$_importFields = CRM_Core_BAO_Cache::$_cache = CRM_Core_DAO::$_dbColumnValueCache = NULL;
     CRM_Core_OptionGroup::flushAll();
     CRM_Utils_PseudoConstant::flushAll();
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:19,代码来源:System.php

示例3: setItem

 /**
  * Store an item in the DB cache.
  *
  * @param object $data
  *   (required) A reference to the data that will be serialized and stored.
  * @param string $group
  *   (required) The group name of the item.
  * @param string $path
  *   (required) The path under which this item is stored.
  * @param int $componentID
  *   The optional component ID (so componenets can share the same name space).
  */
 public static function setItem(&$data, $group, $path, $componentID = NULL)
 {
     if (self::$_cache === NULL) {
         self::$_cache = array();
     }
     $dao = new CRM_Core_DAO_Cache();
     $dao->group_name = $group;
     $dao->path = $path;
     $dao->component_id = $componentID;
     // get a lock so that multiple ajax requests on the same page
     // dont trample on each other
     // CRM-11234
     $lock = Civi::lockManager()->acquire("cache.{$group}_{$path}._{$componentID}");
     if (!$lock->isAcquired()) {
         CRM_Core_Error::fatal();
     }
     $dao->find(TRUE);
     $dao->data = serialize($data);
     $dao->created_date = date('YmdHis');
     $dao->save(FALSE);
     $lock->release();
     $dao->free();
     // cache coherency - refresh or remove dependent caches
     $argString = "CRM_CT_{$group}_{$path}_{$componentID}";
     $cache = CRM_Utils_Cache::singleton();
     $data = unserialize($dao->data);
     self::$_cache[$argString] = $data;
     $cache->set($argString, $data);
     $argString = "CRM_CT_CI_{$group}_{$componentID}";
     unset(self::$_cache[$argString]);
     $cache->delete($argString);
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:44,代码来源:Cache.php

示例4: setItem

 /**
  * Store an item in the DB cache.
  *
  * @param object $data
  *   (required) A reference to the data that will be serialized and stored.
  * @param string $group
  *   (required) The group name of the item.
  * @param string $path
  *   (required) The path under which this item is stored.
  * @param int $componentID
  *   The optional component ID (so componenets can share the same name space).
  */
 public static function setItem(&$data, $group, $path, $componentID = NULL)
 {
     if (self::$_cache === NULL) {
         self::$_cache = array();
     }
     // get a lock so that multiple ajax requests on the same page
     // dont trample on each other
     // CRM-11234
     $lock = Civi::lockManager()->acquire("cache.{$group}_{$path}._{$componentID}");
     if (!$lock->isAcquired()) {
         CRM_Core_Error::fatal();
     }
     $table = self::getTableName();
     $where = self::whereCache($group, $path, $componentID);
     $id = CRM_Core_DAO::singleValueQuery("SELECT id FROM {$table} WHERE {$where}");
     $now = date('Y-m-d H:i:s');
     // FIXME - Use SQL NOW() or CRM_Utils_Time?
     $dataSerialized = serialize($data);
     // This table has a wonky index, so we cannot use REPLACE or
     // "INSERT ... ON DUPE". Instead, use SELECT+(INSERT|UPDATE).
     if ($id) {
         $sql = "UPDATE {$table} SET data = %1, created_date = %2 WHERE id = %3";
         $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($dataSerialized, 'String'), 2 => array($now, 'String'), 3 => array($id, 'Int')));
     } else {
         $insert = CRM_Utils_SQL_Insert::into($table)->row(array('group_name' => $group, 'path' => $path, 'component_id' => $componentID, 'data' => $dataSerialized, 'created_date' => $now));
         $dao = CRM_Core_DAO::executeQuery($insert->toSQL());
     }
     $lock->release();
     $dao->free();
     // cache coherency - refresh or remove dependent caches
     $argString = "CRM_CT_{$group}_{$path}_{$componentID}";
     $cache = CRM_Utils_Cache::singleton();
     $data = unserialize($dataSerialized);
     self::$_cache[$argString] = $data;
     $cache->set($argString, $data);
     $argString = "CRM_CT_CI_{$group}_{$componentID}";
     unset(self::$_cache[$argString]);
     $cache->delete($argString);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:51,代码来源:Cache.php


注:本文中的CRM_Core_BAO_Cache::_cache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。