Skip to content
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

In tracker mode plugin system settings should be automatically cached #6728

Closed
tsteur opened this issue Nov 26, 2014 · 2 comments
Closed

In tracker mode plugin system settings should be automatically cached #6728

tsteur opened this issue Nov 26, 2014 · 2 comments
Assignees
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Nov 26, 2014

If a plugin uses the Settings API and uses it in Tracker mode we always query the database to get the values causing many database queries and a lot of overhead. A plugin developer is most likely not aware of such side effects. Even if someone is aware of this one still has to write a lot of code to cache the setting values and one has to know about events, about cache class etc, one has to write many tests see and one has to invalidate the tracker cache manually. Example of such a class: http://pastebin.com/fXBRpFSR . Therefore we should handle this case automatically as part of the platform.

UserSettings are most likely never accessed in Tracker mode as it does not really make sense. To keep the cache small we should only cache SystemSettings automatically. We should also automatically invalidate the tracker cache as soon as someone changes the settings.

There is already a StorageInterface https://github.com/piwik/piwik/blob/master/core/Settings/StorageInterface.php so if we are in Tracker mode we could set maybe another Storage for SystemSettings

@tsteur tsteur added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. labels Nov 26, 2014
@tsteur
Copy link
Member Author

tsteur commented Nov 26, 2014

Requires #6727 to not query the database when creating a Settings instance.

@tsteur tsteur added this to the Piwik 2.10.0 milestone Nov 27, 2014
@tsteur tsteur self-assigned this Nov 27, 2014
tsteur added a commit that referenced this issue Nov 27, 2014
…racker mode.

As soon as a setting is used in tracker mode we will cache it now making it much
easier for developers to use settings in tracker mode and we will no longer
query the database on each tracking request if a setting is requested apart from
cache creation. Refactored the settings API under the hood to make this possible.
The classes were doing things they were not supposed to do. For instance settings
class also took care of storage which it should not and settings class took
care of many validation things that should be done in a setting class. I cleaned
up that code and it is also much better testable now.
@mattab
Copy link
Member

mattab commented Nov 28, 2014

It will make developers life much easier, brilliant

@tsteur tsteur closed this as completed Dec 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

2 participants