-
-
Notifications
You must be signed in to change notification settings - Fork 108
Selection: moved caching related functionality to separate classes #185
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
Conversation
Thanks for pull request. If I understand it, this is a pure refactoring that separates the code into new classes but does not change the functionality? |
@dg Yes, exactly :) |
} | ||
|
||
|
||
public function setGeneralCacheKey(?string $key) |
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.
Because it is targeted to 7.1, you can use return type void.
|
||
|
||
/** | ||
* @param mixed $accessedColumns |
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.
Please don't use property name in @param
. I know that PhpStorm appends it automatically, but better is to be consistent with rest of code.
Btw is it really mixed or array?
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.
It is really mixed
|
||
/** | ||
* Loads cache of previous accessed columns and returns it. | ||
* @return array|bool |
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.
When it returns bool?
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.
This is just move from original class. I wasn't sure so I reather left it as is.
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.
There are more variables that use null
and bool
to distinguish some states. I would like to fix this in second run.
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.
It seems that array_keys() can return only array, or not?
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.
Yes, and it passes tests, fixed.
|
||
|
||
/** | ||
* @param mixed $observeCache |
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.
mixed or bool?
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.
Here iare stored Selection
instances.
Rest fixed |
|
||
|
||
/** | ||
* @param mixed |
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.
$previousAccessedColumns has typehint array and here is mixed
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.
My bad. I copied properties as they were. Fixed on all properties.
/** | ||
* @param mixed | ||
*/ | ||
public function setAccessedColumns($accessedColumns): void |
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.
$accessedColumns has typehint array and here is mixed
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.
Fixed.
|
||
|
||
/** | ||
* @return mixed |
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.
$accessedColumns has typehint array and here is mixed
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.
Fixed
|
||
|
||
/** | ||
* @param mixed |
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.
$observeCache has typehint bool and here is mixed
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.
Fixed, allowed only Selection
.
@dg Anything else I can do so you merge it? |
/** @var string */ | ||
protected $specificCacheKey; | ||
|
||
/** @var mixed of touched columns */ |
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.
What means mixed of
? Is it array or not?
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.
There was lot of mess arround mixed properties, so I get rid of them and simplify code in separate commit. Let me know what you think.
|
||
|
||
/** | ||
* @return mixed |
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.
It seems according to the code that it is array|null
, or not? For getReferenced
too.
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.
Yes, you are right
|
||
public function setAccessedColumn(string $key, bool $value): void | ||
{ | ||
if (!$this->cache) { |
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.
Just such a stupid thing, maybe positive condition can be used here and in setAccessedColumns
if ($this->cache) {
$this->accessedColumns[$key] = $value;
}
```
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.
Fixed on both places.
Now it look much better, thanks! |
/** | ||
* @return array|null | ||
*/ | ||
public function &getReferencing(string $generalCacheKey) |
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.
Sry, now I realized that it can be written native as &getReferencing(string $generalCacheKey): ?array
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.
Yes, I should realize that too. Fixed
Do you want to have two commits, one with mixed and the other without mixed properties? |
Thanks, great! |
@dg Cache implementation is a long term problem in
NDBT
. While this is definitely not perfect, it's a starting point from which I would like to continue makingNDBT
code more clear, which wil help in future development. I spent two days with this, so I hope you appreciate it. Also, if you agree, I can maintain this repo as we spoken on NettCamp. There is lot for review and merge.