/** * Internal cleaning process. * * @param boolean $cleanAll * * @return void */ protected function process($cleanAll = true) { $key = dba_firstkey($this->cache->getDba()); while ($key !== false && $key !== null) { if (true === $cleanAll) { $this->cache->delete($key); } else { $this->cache->get($key); } $key = dba_nextkey($this->cache->getDba()); } dba_optimize($this->cache->getDba()); }
/** * changes ordering of items * * @param int $id - id of moved element * @param string $direction - up, down */ function move($id, $direction = '') { $this->Access->checkAccess('slides', 'u'); $error = false; if (empty($id) || !in_array($direction, array('up', 'down'))) { $error = true; } $currentItem = $this->Slide->read(null, $id); $currentOrderId = $currentItem['Slide']['ordering']; if ($direction == 'up') { $newItem = $this->Slide->find('first', array('conditions' => array('ordering <' => $currentOrderId), 'order' => 'ordering DESC')); } if ($direction == 'down') { $newItem = $this->Slide->find('first', array('conditions' => array('ordering >' => $currentOrderId), 'order' => 'ordering ASC')); } if (empty($currentItem) || empty($newItem)) { $error = true; } $newOrderId = $newItem['Slide']['ordering']; $currentItem['Slide']['ordering'] = $newOrderId; $newItem['Slide']['ordering'] = $currentOrderId; if (!$this->Slide->save($currentItem) || !$this->Slide->save($newItem)) { Cache::delete('slides'); $error = true; } else { Cache::delete('slides'); } if (!$error) { $this->Session->setFlash(__('The ordering has been changed'), 'flash_success'); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The ordering could not be changed. Please, try again.'), 'flash_error'); $this->redirect(array('action' => 'index')); } }
public function testDeleteCallsRedisDeleteMethod() { $redis = $this->getMockBuilder('\\Redis')->getMock(); $redis->expects($this->once())->method('delete')->with('prefix:key')->willReturn(true); $cache = new Cache($redis, 'prefix'); $this->assertTrue($cache->delete('key')); }
/** * 编辑某个页面的文案 * * @access public * @return void */ public function admin_edit($name) { $miscs = Configure::read('misc'); if (!isset($miscs[$name])) { throw new NotFoundException(__('Invalid misc post')); } $post = $this->MiscPost->getPost($miscs[$name]['title']); if (empty($post)) { $this->_init_posts($miscs); $post = $this->MiscPost->getPost($miscs[$name]['title']); } if ($this->request->is('post') || $this->request->is('put')) { if ($this->MiscPost->save($this->request->data, false)) { $this->Session->setFlash(__('The content has been saved'), 'success'); $post = $this->MiscPost->getPost($miscs[$name]['title']); Cache::delete('articles', 'short'); Cache::delete('articles_mobile', 'short'); } else { $this->Session->setFlash(__('The content could not be saved. Please, try again.'), 'error'); } } else { $this->request->data = $post; } $this->set('post', $post); }
public function validate(Validation $array, $save = FALSE) { // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); // merge unvalidated fields, in case the subclass has set any. if (!isset($this->unvalidatedFields)) { $this->unvalidatedFields = array(); } $this->unvalidatedFields = array_merge($this->unvalidatedFields, array('validation_rules', 'public', 'multi_value', 'deleted')); $array->add_rules('caption', 'required'); $array->add_rules('data_type', 'required'); if (array_key_exists('data_type', $array->as_array()) && $array['data_type'] == 'L') { if (empty($array['termlist_id'])) { $array->add_rules('termlist_id', 'required'); } else { array_push($this->unvalidatedFields, 'termlist_id'); } } $array->add_rules('system_function', 'length[1,30]'); $parent_valid = parent::validate($array, $save); // clean up cached required fields in case validation rules have changed $cache = Cache::instance(); $cache->delete_tag('required-fields'); if ($save && $parent_valid) { // clear the cache used for attribute datatype and validation rules since the attribute has changed $cache = new Cache(); // Type is the object name with _attribute stripped from the end $type = substr($this->object_name, 0, strlen($this->object_name) - 10); $cache->delete('attrInfo_' . $type . '_' . $this->id); } return $save && $parent_valid; }
function delete($key) { parent::delete($key); $key = SITE_NAME . "|{$key}"; $varkey = $this->_hash_key($key); return @shm_remove_var($this->shmid, $varkey); }
function delete($key) { // Delete from static cache parent::delete($this->key($key)); // Remove from memcache. return $this->memcache->delete($this->key($key)); }
/** * Vote * @author vovich * @param unknown_type $model * @param unknown_type $modelId * @param unknown_type $point * @return JSON */ function voting($model, $modelId, $delta) { Configure::write('debug', 0); $this->layout = false; $result = array("error" => "", "sum" => 0, "votes_plus" => 0, "votes_minus" => 0); $userId = $this->Access->getLoggedUserID(); if (!$this->RequestHandler->isAjax()) { $this->redirect($_SERVER['HTTP_REFERER']); } if ($userId == VISITOR_USER || !$userId) { $result['error'] = "Access error, please login."; } elseif (!$this->Access->getAccess('Vote_' . $model, 'c')) { $result['error'] = "You can not vote for this " . $model . "<BR> please logg in "; } else { $result['error'] = $this->Vote->canVote($model, $modelId, $userId); } $data['model'] = Sanitize::paranoid($model); $data['model_id'] = Sanitize::paranoid($modelId); $data['user_id'] = $userId; $data['delta'] = $delta; if (Sanitize::paranoid($model) == 'Image') { Cache::delete('last_images'); } elseif (Sanitize::paranoid($model) == 'Video') { Cache::delete('last_images'); } if (empty($result['error'])) { $points = $this->Vote->add($data); $result['votes_plus'] = $points['votes_plus']; $result['votes_minus'] = $points['votes_minus']; $result['sum'] = $points['votes_plus'] - $points['votes_minus']; } exit($this->Json->encode($result)); }
/** * 执行清空缓存 * @return void */ public function do_task() { if (!empty($this->task_data)) { $user_id = $this->task_data['user_id']; $added_ids = $this->task_data['added_ids']; $updated_ids = $this->task_data['updated_ids']; $deleted_ids = $this->task_data['deleted_ids']; $recycled_ids = $this->task_data['recycled_ids']; $ids = array_merge($added_ids, $updated_ids, $deleted_ids); if ($updated_ids or $recycled_ids or $deleted_ids) { $this->update_cache($user_id, 'recycled_list_update'); } if (!empty($ids) or $this->is_snapshot) { Category_Model::instance()->clear_cache($user_id); } if (!empty($ids)) { foreach ($ids as $id) { $this->cache->delete($this->cache_pre . 'find_by_id_' . $user_id . '_' . $id); } $this->cache->delete($this->cache_pre . 'get_list_' . $user_id); $this->cache->delete($this->cache_pre . 'get_count_' . $user_id); Friend_Model::instance()->del_user_link_cache($user_id); } } }
public function delete($guid = null) { $cache = new Cache('note'); $cache->delete($this->note->guid); $this->note = new Note(); return self::_noteStore()->deleteNote(AUTH_TOKEN, $guid ?: $this->guid); }
public function destroy($id) { if (!empty($this->cacheKey)) { Cache::delete($id, $this->cacheKey); } return parent::destroy($id); }
function editUser($parameters, $user_id=null){ if($user_id==$parameters->{'id'}){ $user['User']['id']=$parameters->{'id'}; if(($parameters->{'username'})){ $user['User']['username']=$parameters->{'username'}; } if(($parameters->{'status'})){ $user['User']['status']=$parameters->{'status'}; } if(($parameters->{'fullname'})){ $user['User']['fullname']=$parameters->{'fullname'}; } if(($parameters->{'email'})){ $user['User']['email']=$parameters->{'email'}; } $this->primaryKey='id'; if($this->save($user['User'])){ $ck = 'viewgetuser_'.$user_id; Cache::delete($ck,'userauth'); $user=$this->getUser($user_id); return $user; } else { return false; } } else { return false; } }
protected function _clearCache($type = null) { foreach (Cache::read($this->cachePrefix()) as $key => $value) { Cache::delete($key); } return parent::_clearCache(); }
function delete($key) { parent::delete($key); $key = $this->_mangle_key($key); $fn = $this->cache_dir . DS . $key; return is_file($fn) ? @unlink($fn) : false; }
public function afterDelete() { parent::afterDelete(); if ($this->id) { Cache::delete('getPracticeTitleById' . $this->id); } }
/** * Deletes the cache of a controller by name or array of properties. * * @param mixed $key_definition Array of keys=>values that define the cache, * or just a string that will be used as "name". */ public function deleteCache($key_definition) { if (!is_array($key_definition)) { $key_definition = array('name' => $key_definition); } return $this->cache->delete($this->_getFinalCacheKeyName($key_definition)); }
function afterSave(&$model, $created = false) { //////// Clear cache //////// if (Configure::read('admin') == true) { Cache::delete('BlogCategoryList'); } }
/** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); Cache::delete('object_map', '_cake_core_'); App::build(); CakePlugin::unload(); }
/** * Clears all dynamic routes from the cache * * @param bool $created whether the route was created or not * @return bool */ public function afterSave($created) { if (Configure::read('DynamicRoute.cacheKey')) { Cache::delete(Configure::read('DynamicRoute.cacheKey')); } return true; }
function index() { if (!($cachedate = Cache::read('cached_date'))) { Cache::delete('cached_date'); } $current = strtotime(date('Y-m-d G:i:s')); $checktime = strtotime(date('Y-m-d G:i:s', mktime(10, 0, 0, date("m"), date("d"), date("Y")))); $dateObject = new DateTime(date('Y-m-d G:i:s')); $today = $dateObject->format('Y-m-d'); $yesterday = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))); $this->set('title', 'HamroAwaz'); $this->loadModel('Categorymanager'); $this->loadModel('Newsmanager'); $qcat = $this->Categorymanager->find('all'); $this->set('cat', $qcat); if ($checktime >= $current) { $arr['conditions'] = array('created_date' => $yesterday); $slider = $this->Newsmanager->find('all', $arr); $this->set('slider', $slider); $q = $this->Newsmanager->find('all', array('conditions' => array('created_date' => $yesterday, 'is_headline' => 1), 'order' => array('id' => 'DESC'), 'limit' => 5)); // debug($q);die(); $this->set('val', $q); } if ($checktime < $current) { $arr['conditions'] = array('created_date' => $today); $slider = $this->Newsmanager->find('all', $arr); $this->set('slider', $slider); //die('lalustine'); $q = $this->Newsmanager->find('all', array('conditions' => array('created_date' => $today, 'is_headline' => 1), 'order' => array('id' => 'DESC'), 'limit' => 5)); $this->set('val', $q); } }
public function tearDown() { Cache::delete(UrlCacheManager::$cacheKey, '_cake_core_'); Cache::delete(UrlCacheManager::$cachePageKey, '_cake_core_'); Configure::delete('UrlCache'); parent::tearDown(); }
function test_delete() { $c = new Cache(); $this->assertEquals($c->get('foo'), 'Some value'); $this->assertTrue($c->delete('foo')); $this->assertFalse($c->get('foo')); }
function delete($key) { foreach ($this->settings['stack'] as $engine => $stack) { Cache::delete($key, $engine); } return true; }
private function __deleteUserCache() { $key = 'team_' . $this->Authorization->User->Team->id(); if (!$key) { $key = $this->Authorization->User->id(); } Cache::delete('payments_total_' . $key, 'expenses'); }
public function _destroy($id) { if ($id) { return Cache::delete($id, $this->savePath); } else { return Cache::flush($this->savePath); } }
/** * Finds all slugs and saves them to Cache * * @return all slugs in an array */ function cacheSlugs() { Cache::delete('simple_page_slugs'); $data = $this->find('all', array('fields' => 'slug')); $slugs = Set::extract('/SimplePage/slug', $data); Cache::write('simple_page_slugs', $slugs); return $slugs; }
function testDeleteCache() { $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('delete_test', $data); $this->assertTrue($result); $result = Cache::delete('delete_test'); $this->assertTrue($result); }
/** * end a test * * @return void **/ function tearDown() { parent::tearDown(); unset($this->Helper); Cache::delete(AssetConfig::CACHE_BUILD_TIME_KEY, AssetConfig::CACHE_CONFIG); Cache::drop(AssetConfig::CACHE_CONFIG); @unlink(TMP . AssetConfig::BUILD_TIME_FILE); }
/** * Note that this function does not delete the global area's stack. * You probably want to call the "delete" method of the Stack model instead. */ public static function deleteByName($arHandle) { $db = Loader::db(); $r = $db->Execute('select cID from Areas where arHandle = ? and arIsGlobal = 1', array($arHandle)); while ($row = $r->FetchRow()) { $a = Cache::delete('area', $row['cID'] . ':' . $arHandle); } $db->Execute('delete from Areas where arHandle = ? and arIsGlobal = 1', array($arHandle)); }
public static function clearCache() { if ($cache_list = Cache::read('posts-cachelist')) { foreach ($cache_list as $cache_entry) { Cache::delete($cache_entry); } Cache::delete('posts-cachelist'); } }