Skip to content

Instantly share code, notes, and snippets.

@cebe
Forked from Abiraman/Mongodb Cache
Last active September 27, 2018 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cebe/70d8de1d0fa6c5bc117ecf5037b9d99a to your computer and use it in GitHub Desktop.
Save cebe/70d8de1d0fa6c5bc117ecf5037b9d99a to your computer and use it in GitHub Desktop.
// My code
<?php
$collection=\app\models\Notifications::getCollection()->name;
if ($this->beginCache('Notifghjgjhgication', ['dependency' => [
'class' => 'yii\caching\DbQueryDependency',
'query' => \app\models\Notifications::find()->where(["receiver_type" => "vendor", "receiver_id" => \Yii::$app->user->identity->_id, 'read_status' => FALSE]),
'method' => 'count',
]])) {?>
<li class="dropdown" id="Notification-list-container">
<?= Yii::$app->runAction('/notification/default/notificationlist') ?>
</li>
<?php $this->endCache(); }?>
exception 'yii\base\InvalidConfigException' with message '"yii\caching\DbQueryDependency::$query" should be an instance of "yii\db\QueryInterface".' in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/caching/DbQueryDependency.php:78
Stack trace:
#0 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/caching/Dependency.php(56): yii\caching\DbQueryDependency->generateDependencyData(Object(yii\redis\Cache))
#1 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/caching/Cache.php(226): yii\caching\Dependency->evaluateDependency(Object(yii\redis\Cache))
#2 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/widgets/FragmentCache.php(116): yii\caching\Cache->set(Array, Array, 60, Object(yii\caching\DbQueryDependency))
#3 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Widget.php(109): yii\widgets\FragmentCache->run()
#4 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/View.php(552): yii\base\Widget::end()
#5 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/views/layouts/main.php(98): yii\base\View->endCache()
#6 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/View.php(336): require('/Applications/M...')
#7 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/View.php(254): yii\base\View->renderPhpFile('/Applications/M...', Array)
#8 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Controller.php(399): yii\base\View->renderFile('/Applications/M...', Array, Object(app\controllers\SiteController))
#9 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Controller.php(385): yii\base\Controller->renderContent('\n<div id="banne...')
#10 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/controllers/SiteController.php(63): yii\base\Controller->render('index')
#11 [internal function]: app\controllers\SiteController->actionIndex()
#12 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#14 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('', Array)
#15 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('', Array)
#16 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#17 /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/web/index.php(12): yii\base\Application->run()
#18 {main}
Copy Stacktrace
Search Stackoverflow
Search Google
Exception
Invalid Configuration – yii\base\InvalidConfigException
"yii\caching\DbQueryDependency::$query" should be an instance of "yii\db\QueryInterface".
1. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/caching/DbQueryDependency.php at line 78
69707172737475767778798081828384858687
*/
protected function generateDependencyData($cache)
{
$db = $this->db;
if ($db !== null) {
$db = Instance::ensure($db);
}
if (!$this->query instanceof QueryInterface) {
throw new InvalidConfigException('"' . get_class($this) . '::$query" should be an instance of "yii\db\QueryInterface".');
}
if (!empty($db->enableQueryCache)) {
// temporarily disable and re-enable query caching
$originEnableQueryCache = $db->enableQueryCache;
$db->enableQueryCache = false;
$result = $this->executeQuery($this->query, $db);
$db->enableQueryCache = $originEnableQueryCache;
} else {
2. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/caching/Dependency.php at line 56 – yii\caching\DbQueryDependency::generateDependencyData(yii\redis\Cache)
50515253545556575859606162
$hash = $this->generateReusableHash();
if (!array_key_exists($hash, self::$_reusableData)) {
self::$_reusableData[$hash] = $this->generateDependencyData($cache);
}
$this->data = self::$_reusableData[$hash];
} else {
$this->data = $this->generateDependencyData($cache);
}
}
/**
* Returns a value indicating whether the dependency has changed.
* @deprecated since version 2.0.11. Will be removed in version 2.1. Use [[isChanged()]] instead.
3. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/caching/Cache.php at line 226 – yii\caching\Dependency::evaluateDependency(yii\redis\Cache)
220221222223224225226227228229230231232
{
if ($duration === null) {
$duration = $this->defaultDuration;
}
if ($dependency !== null && $this->serializer !== false) {
$dependency->evaluateDependency($this);
}
if ($this->serializer === null) {
$value = serialize([$value, $dependency]);
} elseif ($this->serializer !== false) {
$value = call_user_func($this->serializer[0], [$value, $dependency]);
}
4. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/widgets/FragmentCache.php at line 116 – yii\caching\Cache::set(['yii\widgets\FragmentCache', 'Notifghjgjhgication'], [' ...', null], 60, yii\caching\DbQueryDependency)
110111112113114115116117118119120121122
return;
}
if (is_array($this->dependency)) {
$this->dependency = Yii::createObject($this->dependency);
}
$data = [$content, $this->getDynamicPlaceholders()];
$this->cache->set($this->calculateKey(), $data, $this->duration, $this->dependency);
echo $this->updateDynamicContent($content, $this->getDynamicPlaceholders());
}
}
/**
* @var string|bool the cached content. False if the content is not cached.
5. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Widget.php at line 109 – yii\widgets\FragmentCache::run()
103104105106107108109110111112113114115
{
if (!empty(static::$stack)) {
$widget = array_pop(static::$stack);
if (get_class($widget) === get_called_class()) {
/* @var $widget Widget */
if ($widget->beforeRun()) {
$result = $widget->run();
$result = $widget->afterRun($result);
echo $result;
}
return $widget;
}
6. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/View.php at line 552 – yii\base\Widget::end()
546547548549550551552553554555556557558
/**
* Ends fragment caching.
*/
public function endCache()
{
FragmentCache::end();
}
/**
* Marks the beginning of a page.
*/
public function beginPage()
7. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/views/layouts/main.php at line 98 – yii\base\View::endCache()
9293949596979899100101102103104
'class' => 'yii\caching\DbQueryDependency',
'method' =>function(){ return \app\models\Notifications::find()->where(["receiver_type" => "vendor", "receiver_id" => \Yii::$app->user->identity->_id, 'read_status' => FALSE])->count();},
]])) {?>
<li class="dropdown" id="Notification-list-container">
<?= Yii::$app->runAction('/notification/default/notificationlist') ?>
</li>
<?php $this->endCache(); }?>
<li class="dropdown">
<?= Yii::$app->runAction('/appointment/default/appointmentlist') ?>
</li>
<?php } ?>
</ul>
8. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/View.php at line 336 – require('/Applications/MAMP/htdocs/DEVELO...')
9. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/View.php at line 254 – yii\base\View::renderPhpFile('/Applications/MAMP/htdocs/DEVELO...', ['content' => ' <div id="banner-container"> ...'])
10. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Controller.php at line 399 – yii\base\View::renderFile('/Applications/MAMP/htdocs/DEVELO...', ['content' => ' <div id="banner-container"> ...'], app\controllers\SiteController)
11. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Controller.php at line 385 – yii\base\Controller::renderContent(' <div id="banner-container"> ...')
12. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/controllers/SiteController.php at line 63 – yii\base\Controller::render('index')
57585960616263646566676869
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex() {
return $this->render('index');
}
/**
* Logout action.
*
* @return string
13. app\controllers\SiteController::actionIndex()
14. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([app\controllers\SiteController, 'actionIndex'], [])
15. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Controller.php at line 157 – yii\base\InlineAction::runWithParams([])
16. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Module.php at line 528 – yii\base\Controller::runAction('', [])
17. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/web/Application.php at line 103 – yii\base\Module::runAction('', [])
18. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/vendor/yiisoft/yii2/base/Application.php at line 386 – yii\web\Application::handleRequest(yii\web\Request)
19. in /Applications/MAMP/htdocs/DEVELOPMENT/Zebyt/web/vendor/web/index.php at line 12 – yii\base\Application::run()
6789101112
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
$config = require(__DIR__ . '/../config/web.php');
(new yii\web\Application($config))->run();
$_COOKIE = [
'_ga' => 'GA1.1.1804245043.1537959729',
'_gid' => 'GA1.1.1436846352.1537959729',
'_identity' => 'e745b53adb374e0535b275a2155cc7d21d208ab04f2e054dc8083494eeeab2f4a:2:{i:0;s:9:"_identity";i:1;s:41:"["5ad0d64ea53be308757b27c1",null,2592000]";}',
'PHPSESSID' => '3a99ad59ad252c5773f8180ed3973bdd',
'_csrf' => 'bb55906239221672e1c8b0ba0dff5dc75fe7c9f3d7d49286050f8080fb5f2ba4a:2:{i:0;s:5:"_csrf";i:1;s:32:"BHCd6mp4d-8XWUwJ0rYTpuZCEA15pSGz";}',
];
$_SESSION = [
'__flash' => [],
'__returnUrl' => '/DEVELOPMENT/Zebyt/web/vendor/web/',
'__id' => '5ad0d64ea53be308757b27c1',
'user.shopInfo' => [
'_id' => '5ad0d738a53be318dd228e11',
'category' => [
'586cbfba6790863fbed1a3e9',
'586cd7826790863fbed1a40c',
],
'primary_services' => [
'5826bb0ad9e55807b177da68',
'586cc1d26790863fbed1a3ec',
'586cc1f96790863fbed1a3ee',
],
'shop_name' => 'Bright Sports Academy',
'description' => 'Choose Bright Sports Academy for the best tennis and Swimming instruction.
We will work with you and your young ones needs to choose training method. Our goal is to do our best to train our students with the best instruction our academy has to offer. Contact us now for more information.
Bright Sport Academy has created more professional players from the junior ranks than almost any other coach in the world.',
'address' => '19608, Pruneridge Avenue',
'city' => 'Cupertino',
'state' => 'CA',
'country' => 'US',
'zipcode' => '95014',
'latlng' => [
'type' => 'Point',
'coordinates' => [
-122.0157856000000009544237400405108928680419921875,
37.33430729999999897472662269137799739837646484375,
],
],
'no_of_participation' => 4,
'no_completed_quotes' => 0,
'star_rate' => 5,
'no_of_reviews' => 6,
'created_at' => 1523636023,
'updated_at' => 1537963698,
'shop_contact_number' => [
'office' => '6506653878',
'ext' => '',
'mobile' => '+16506653878',
],
'social_media_urls' => [
'facebook' => 'https://www.facebook.com/zoyap/',
'website' => 'https://www.zoyap.com',
'twitter' => 'https://twitter.com/zoyap',
'youtube' => 'https://www.youtube.com/zoyap',
'linkedin' => '',
],
'vendor_id' => '5ad0d64ea53be308757b27c1',
'year_started' => '2001',
'shop_registarion_number' => 'APR2914872',
'shop_tax_id' => '98-7654321',
'shop_email' => 'zebytvendor2@gmail.com',
'logo' => 'https://s3-us-west-1.amazonaws.com/zoyap20-vendor/5ad0d64ea53be308757b27c1/logo/1529265899.jpg',
'business_type' => 'individual',
],
'user.accessToken' => '2e3c17542f3d22418a3aaecea43a46db434fe240',
'user.refreshToken' => '4f1fb3e138c897b9b28ef39bd87ba7e380c55bf4',
'user.expiresIn' => 86400,
];
Yii Framework
2018-09-27, 03:09:48
Apache/2.2.34 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/5.6.32 mod_ssl/2.2.34 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0
Yii Framework/2.0.15.1
2.0.15.1 PHP 5.6.32
Status 500 Route site/index
Log 67 1
Time 1,804 ms Memory 11.758 MB
Asset Bundles 14
Guest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment