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


PHP caching\TagDependency类代码示例

本文整理汇总了PHP中yii\caching\TagDependency的典型用法代码示例。如果您正苦于以下问题:PHP TagDependency类的具体用法?PHP TagDependency怎么用?PHP TagDependency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->model === null) {
         throw new InvalidConfigException("Model should be set for WarehousesRemains widget");
     }
     $state = $this->model->getWarehousesState();
     $activeWarehousesIds = Warehouse::activeWarehousesIds();
     $remains = [];
     foreach ($state as $remain) {
         $remains[$remain->warehouse_id] = $remain;
         if (($key = array_search($remain->warehouse_id, $activeWarehousesIds)) !== false) {
             unset($activeWarehousesIds[$key]);
         }
     }
     // if we have new warehouses that not represented in warehouses state
     if (count($activeWarehousesIds) > 0) {
         foreach ($activeWarehousesIds as $id) {
             // create new record with default values
             $remain = new WarehouseProduct();
             $remain->warehouse_id = $id;
             $remain->product_id = $this->model->id;
             $remain->save();
             // add to remains
             $remains[$remain->warehouse_id] = $remain;
         }
         TagDependency::invalidate(Yii::$app->cache, ActiveRecordHelper::getObjectTag($this->model->className(), $this->model->id));
     }
     return $this->render('warehouses-remains', ['model' => $this->model, 'remains' => $remains]);
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:32,代码来源:WarehousesRemains.php

示例2: down

 public function down()
 {
     $tbl = '{{%backend_menu}}';
     $this->update($tbl, ['route' => '/shop/backend-order/index'], ['route' => 'shop/backend-order/index']);
     $this->update($tbl, ['route' => '/shop/backend-customer/index'], ['route' => 'shop/backend-customer/index']);
     $this->update($tbl, ['route' => '/shop/backend-contragent/index'], ['route' => 'shop/backend-contragent/index']);
     \yii\caching\TagDependency::invalidate(Yii::$app->cache, [\devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag(\app\backend\models\BackendMenu::className())]);
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:8,代码来源:m150723_095512_backend_menu_fixes.php

示例3: down

 public function down()
 {
     $this->dropTable('{{%addon}}');
     $this->dropTable('{{%addon_category}}');
     $this->dropTable('{{%addon_bindings}}');
     $this->delete('{{%object}}', ['name' => 'Addon']);
     $this->delete('{{%backend_menu}}', ['name' => 'Addons']);
     \yii\caching\TagDependency::invalidate(Yii::$app->cache, [\devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag(\app\backend\models\BackendMenu::className())]);
     $this->dropColumn('{{%order_item}}', 'addon_id');
 }
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:10,代码来源:m150827_075105_product_addons.php

示例4: _deleteCache

 /**
  * Deletes the cache for the frontend and backend loaded data using makeCacheTag method
  *
  * @param Event $event
  */
 public function _deleteCache(Event $event)
 {
     $frontend = [0, 1];
     $backend = [0, 1];
     foreach ($frontend as $_f) {
         foreach ($backend as $_b) {
             TagDependency::invalidate(Yii::$app->cache, self::makeCacheTag($_f, $_b));
         }
     }
 }
开发者ID:AtuinCMS,项目名称:apps,代码行数:15,代码来源:App.php

示例5: testInvalidate

 public function testInvalidate()
 {
     $cache = new FileCache(['cachePath' => '@yiiunit/runtime/cache']);
     // single tag test
     $cache->set('a1', 11, 0, new TagDependency(['tags' => 't1']));
     $cache->set('a2', 12, 0, new TagDependency(['tags' => 't1']));
     $cache->set('b1', 21, 0, new TagDependency(['tags' => 't2']));
     $cache->set('b2', 22, 0, new TagDependency(['tags' => 't2']));
     $this->assertEquals(11, $cache->get('a1'));
     $this->assertEquals(12, $cache->get('a2'));
     $this->assertEquals(21, $cache->get('b1'));
     $this->assertEquals(22, $cache->get('b2'));
     TagDependency::invalidate($cache, 't1');
     $this->assertFalse($cache->get('a1'));
     $this->assertFalse($cache->get('a2'));
     $this->assertEquals(21, $cache->get('b1'));
     $this->assertEquals(22, $cache->get('b2'));
     TagDependency::invalidate($cache, 't2');
     $this->assertFalse($cache->get('a1'));
     $this->assertFalse($cache->get('a2'));
     $this->assertFalse($cache->get('b1'));
     $this->assertFalse($cache->get('b2'));
     // multiple tag test
     $cache->set('a1', 11, 0, new TagDependency(['tags' => ['t1', 't2']]));
     $cache->set('a2', 12, 0, new TagDependency(['tags' => 't1']));
     $cache->set('b1', 21, 0, new TagDependency(['tags' => ['t1', 't2']]));
     $cache->set('b2', 22, 0, new TagDependency(['tags' => 't2']));
     $this->assertEquals(11, $cache->get('a1'));
     $this->assertEquals(12, $cache->get('a2'));
     $this->assertEquals(21, $cache->get('b1'));
     $this->assertEquals(22, $cache->get('b2'));
     TagDependency::invalidate($cache, 't1');
     $this->assertFalse($cache->get('a1'));
     $this->assertFalse($cache->get('a2'));
     $this->assertFalse($cache->get('b1'));
     $this->assertEquals(22, $cache->get('b2'));
     TagDependency::invalidate($cache, 't2');
     $this->assertFalse($cache->get('a1'));
     $this->assertFalse($cache->get('a2'));
     $this->assertFalse($cache->get('b1'));
     $this->assertFalse($cache->get('b2'));
     $cache->set('a1', 11, 0, new TagDependency(['tags' => ['t1', 't2']]));
     $cache->set('a2', 12, 0, new TagDependency(['tags' => 't1']));
     $cache->set('b1', 21, 0, new TagDependency(['tags' => ['t1', 't2']]));
     $cache->set('b2', 22, 0, new TagDependency(['tags' => 't2']));
     $this->assertEquals(11, $cache->get('a1'));
     $this->assertEquals(12, $cache->get('a2'));
     $this->assertEquals(21, $cache->get('b1'));
     $this->assertEquals(22, $cache->get('b2'));
     TagDependency::invalidate($cache, ['t1', 't2']);
     $this->assertFalse($cache->get('a1'));
     $this->assertFalse($cache->get('a2'));
     $this->assertFalse($cache->get('b1'));
     $this->assertFalse($cache->get('b2'));
 }
开发者ID:howq,项目名称:yii2,代码行数:55,代码来源:TagDependencyTest.php

示例6: setCustomization

 public function setCustomization($block, $customization = [])
 {
     $this->validateBemSelector($block);
     static::$identityMap[$block] = $customization;
     $filename = $this->storagePath . $block . 'json';
     $result = file_put_contents($filename, Json::encode($customization)) !== false;
     if ($result === true) {
         TagDependency::invalidate(Yii::$app->cache, ["GlobalCustomization:{$block}"]);
     }
     return $result;
 }
开发者ID:DevGroup-ru,项目名称:dotplant-monster,代码行数:11,代码来源:BemCustomizationRepository.php

示例7: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $n = 0;
     switch ($this->action) {
         case CategoryMovementsButtons::ADD_ACTION:
             $n = $this->add();
             break;
         case CategoryMovementsButtons::MOVE_ACTION:
             $n = $this->move();
             break;
     }
     $tags = [];
     foreach ($this->items as $id) {
         $tags[] = ActiveRecordHelper::getObjectTag(Product::className(), $id);
     }
     TagDependency::invalidate(Yii::$app->cache, $tags);
     Yii::$app->session->setFlash('info', Yii::t('app', 'Items updated: {n}', ['n' => $n]));
 }
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:21,代码来源:CategoryMovementsAction.php

示例8: moveCategory

 /**
  * Переносик категорию
  * @param $parent integer
  * @param $position integer
  * @return array
  */
 public function moveCategory($parent, $position)
 {
     // Очищаем ВСЕ кеши категорий
     TagDependency::invalidate(Yii::$app->cache, ['category']);
     $result = false;
     $counts = [];
     $parentCat = Category::findOne($parent);
     // Новый родитель
     $oldParentCat = Category::findOne($this->parent);
     // Старый родитель
     $this->parent = $parent;
     // Если position = 0
     if ($position === 0) {
         // Добавляем в начало
         $result = $this->prependTo($parentCat);
     } else {
         // Иначе, ищем категорию, после которой нужно добавить
         $prevCategory = end($parentCat->children(1)->andWhere(['not in', 'id', $this->id])->limit($position)->all());
         // Если нужный элемент найден
         if ($prevCategory !== null) {
             // Добавляем новый после нее
             $result = $this->insertAfter($prevCategory);
         }
     }
     // Пересчитываем cnt_products для всех НОВЫХ и СТАРЫХ родительских категорий
     // Если товаров в категории нет, то и пересчитывать ничего не нужно
     if (0 < $this->cnt_products) {
         $parents = array_unique(array_merge([$oldParentCat->id], Category::getParentsIds($oldParentCat->id), [(int) $this->parent], Category::getParentsIds($this->parent)));
         foreach ($parents as $p) {
             $parentCategory = Category::findOne($p);
             $parentCategory->cnt_products = Product::findAllInCatsAndSubCategories($parentCategory)->count();
             $parentCategory->save();
             $counts[$parentCategory->id] = $parentCategory->cnt_products;
         }
     }
     return ['result' => $result, 'counts' => $counts];
 }
开发者ID:andreykluev,项目名称:yii2-catalog-module,代码行数:43,代码来源:BaseCategory.php

示例9: invalidate

 /**
  * Ivalidate cache
  */
 protected function invalidate()
 {
     if (Configs::instance()->cache !== null) {
         TagDependency::invalidate(Configs::instance()->cache, self::CACHE_TAG);
     }
 }
开发者ID:luoche,项目名称:iisns,代码行数:9,代码来源:RouteController.php

示例10: beforeSave

 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (!$insert) {
         // reset a cache tag to get a new parent model below
         TagDependency::invalidate(Yii::$app->cache, [ActiveRecordHelper::getCommonTag(self::className())]);
     }
     $this->slug_compiled = $this->compileSlug();
     TagDependency::invalidate(Yii::$app->cache, [ActiveRecordHelper::getCommonTag($this->className()), 'Page:' . $this->slug_compiled]);
     TagDependency::invalidate(Yii::$app->cache, [ActiveRecordHelper::getCommonTag($this->className()), 'Page:' . $this->id . ':0']);
     TagDependency::invalidate(Yii::$app->cache, [ActiveRecordHelper::getCommonTag($this->className()), 'Page:' . $this->id . ':1']);
     if (empty($this->breadcrumbs_label)) {
         $this->breadcrumbs_label = $this->title;
     }
     if (empty($this->h1)) {
         $this->h1 = $this->title;
     }
     return parent::beforeSave($insert);
 }
开发者ID:flarmn,项目名称:dotplant2,代码行数:21,代码来源:Page.php

示例11: invalidate

 /**
  * Ivalidate cache
  */
 public static function invalidate()
 {
     if (Configs::cache() !== null) {
         TagDependency::invalidate(Configs::cache(), self::CACHE_TAG);
     }
 }
开发者ID:max-wen,项目名称:yii2-app-advanced-autoEnv,代码行数:9,代码来源:Route.php

示例12: invalidateCache

 public function invalidateCache()
 {
     TagDependency::invalidate(Yii::$app->cache, self::$cacheKey);
 }
开发者ID:lav45,项目名称:yii2-translated-behavior-demo,代码行数:4,代码来源:Lang.php

示例13: actionDelete

 /**
  * Deletes an existing Book model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $this->findModel($id)->delete();
     \yii\caching\TagDependency::invalidate(Yii::$app->cache, 'books');
     return $this->redirect(['index']);
 }
开发者ID:scarneros,项目名称:yii2-tutorial,代码行数:12,代码来源:BookController.php

示例14: afterDelete

 /**
  * Invalidate cache
  */
 public function afterDelete()
 {
     TagDependency::invalidate(Yii::$app->cache, ContentModule::CACHE_TAG);
     parent::afterDelete();
 }
开发者ID:webvimark,项目名称:ybc-content,代码行数:8,代码来源:ContentTemplateWidget.php

示例15: delete

 static function delete($tags = '')
 {
     TagDependency::invalidate(Yii::$app->cache, $tags);
 }
开发者ID:radiata-cms,项目名称:radiata,代码行数:4,代码来源:CacheHelper.php


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