New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy query cache from yii\db\Command
to yii\db\Query::createCommand()
and yii\db\ActiveQuery::createCommand()
.
#15398
Copy query cache from yii\db\Command
to yii\db\Query::createCommand()
and yii\db\ActiveQuery::createCommand()
.
#15398
Conversation
hubeiwei
commented
Dec 21, 2017
•
edited
edited
Q | A |
---|---|
Is bugfix? | no |
New feature? | yes |
Breaks BC? | no |
Tests pass? | yes |
Fixed issues | - |
Thank you for putting effort in the improvement of the Yii framework. Unfortunately a use case is missing. It is required to get a better understanding of the pull request and helps us to determine the necessity and applicability of the suggested change to the framework. Could you supply us with a use case please? Please be as detailed as possible and show some code! Thanks! This is an automated comment, triggered by adding the label |
Command will check the cache in the query, Query should be able to set the cache
|
yii\db\Command
to yii\db\Query::createCommand()
and yii\db\Active::createCommand()
.yii\db\Command
to yii\db\Query::createCommand()
and yii\db\ActiveQuery::createCommand()
.
I think http://www.yiiframework.com/doc-2.0/guide-caching-data.html#query-caching is enough as a way to achieve it. @yiisoft/reviewers, @yiisoft/core-developers need opinions. |
Yes,I think you can write less code in this way. |
@samdark Is there any reason to not implementing it? IMO it may be useful and will improve consistency. |
Two reasons:
|
|
@samdark |
@rob006 the idea of having it only at connection level was essentially that it can wrap anything and there's no need for more ways to handle it. |
The idea seems to be dropped, since we have: Line 123 in e9bec0d
|
While I personally don't like the idea much, if you think it's fine I'm OK merging it. @cebe, @SilverFire, @klimov-paul thoughts? |
We already have 2 ways to cache a query: $db->cache(function($db) {
return User::find()->all();
}); $cache->getOrSet(['meaningful-key'], function () {
return User::find()->all();
}) But the suggested one can be a shorter and more convenient. I'd suggest to move properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above. Otherwise good to go
…y-cache-from-command-to-query
@SilverFire |
@SilverFire Why did you merge this without any tests? I'm pretty sure that this will not work as expected: Also |
It was accidentally, I'm now working on fix |
See 5bd6ed5 |
I would keep |