定制 intersvyaz/yii-tags-dependency 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

intersvyaz/yii-tags-dependency

最新稳定版本:1.0.1

Composer 安装命令:

composer require intersvyaz/yii-tags-dependency

包简介

Verification of the cache relevance based on Dependency mechanism of Yii framework and tags, which are also stored in cache

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage

Verification of the cache relevance based on Dependency mechanism of Yii framework and tags, which are also stored in cache

Based on idea of Косыгин Александр < http://habrahabr.ru/users/kosalnik/ > described at http://habrahabr.ru/post/159079/

Installation via Composer

php composer.phar require intersvyaz/yii-tags-dependency:*

Configuration

  1. This extension require configured cache

Base Usage

<?php

use Intersvyaz\Cache\TagsDependency;

$cache = \Yii::app()->cache;

// save any value into cache with this dependency
$cache->set('cacheKey', 'cacheValue', 0, new TagsDependency(['A', 'B']));

// check if there is a value in cache
var_dump($cache->get('cacheKey'));

// remove (invalidate) one or several tags
TagsDependency::clearTags(['A']);

// check if cached value is absent in cache
var_dump($cache->get('cacheKey'));

CacheTagBehavior usage

class TestActiveRecord extends \CActiveRecord
{
//    ...
    
    public function behaviors()
    {
        return [
            'cacheTagBehavior' => [
                'class' => CacheTagBehavior::class,
            ]
        ];
    }
    
//    ...
}

// in other code: 

$models = TestActiveRecord::model()->cacheTag(3600, $dependency)->findAll();

// ...

// read query from cache
$models = TestActiveRecord::model()->cacheTag(3600, $dependency)->findAll();

// ...
$model2 = TestActiveRecord::model()->findByPk(2);
$model2->title = 'test';
$model2->save();

// ...

// cache invalid, read query from db
$models = TestActiveRecord::model()->cacheTag(3600, $dependency)->findAll();

统计信息

  • 总下载量: 62.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 9
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-06