static function setItem(&$data, $group, $path, $componentID = null) { $dao = new CRM_Core_DAO_Cache(); $dao->group_name = $group; $dao->path = $path; $dao->component_id = $componentID; $dao->find(true); $dao->data = serialize($data); $dao->save(); }
static function setItem(&$data, $group, $path, $componentID = null) { $dao = new CRM_Core_DAO_Cache(); $dao->group_name = $group; $dao->path = $path; $dao->component_id = $componentID; $dao->find(true); $dao->data = serialize($data); $dao->created_date = date('Ymdhis'); // CRM_Core_Error::debug_var( "Saving $group, $path on {$dao->created_date}", $data ); $dao->save(); $dao->free(); }
/** * 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); }
/** * 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) * * @return void * @static * @access public */ static function setItem(&$data, $group, $path, $componentID = NULL) { $dao = new CRM_Core_DAO_Cache(); $dao->group_name = $group; $dao->path = $path; $dao->component_id = $componentID; $dao->find(TRUE); $dao->data = serialize($data); $dao->created_date = date('YmdHis'); $dao->save(); $dao->free(); }