-
Notifications
You must be signed in to change notification settings - Fork 104
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
[Proposel] Improving the speed and core functionality [v2] #37
Comments
but for how much time we can store in cache if views are increasing in seconds? |
That is the problem we are facing. |
so i think cache cannot be best option for this, because views are always increasing in seconds so we should not update cache again and again in seconds |
Maybe adding an extra counter in the JSON object that's done by incrementing. This could be retrieved in a few miliseconds. Then scheduling a command that recounts this number every hour or day. Edit: Check my draft under draft ideas. |
yes it is a good idea to store the counting of views separately instead of storing a new record on every request that will take a huge space in database as well, and will also be slower while fetching |
But by doing that, we can't ask for the total page views that are maked in the past 30 minutes, 2 days or 2 montsh. I can also make this optional for the users who wants this. functionality. This sounds to me as a nice solution |
yeah this will be not possible to tell views for particular days, what if we make a separate table where we'll have one record for each page with a counter attribute, and using it in simple scenario to fetch just total views of a page but if someone asks for views of last month or last hour etc then use original table like we are using right now |
That's a pretty nice solution. I will also store these time ranges in the seperated table. |
give it a try and check if it works fine and faster, check my edit in above comment as well |
Little update! I have been working on v2 in the past few days and changed the workflow a little bit. I think that I found a sweet solution. When the user try to retrieve the page visits of a specific time range, the returned value will be stored in the cache with a time limit. I wil also work on a new documentation with more info about the workflow and requirements. |
Overview
I think that caching everything could improve the speed very much. This would be a nice addition, but the next thing to discuss is how should the page views be stored. Using a simple counter or storing every page view as a record (it currently works like this). But instead of counting all these page views on every request, the total page views could be stored in dedicated attribute on the model (or different table) as a JSON object.
Draft ideas
Draft one [branch: v2-testing]
There are two tables needed:
page-views
This table is only needed for users who wants to keep track of the historypage-views-counter
The page views table consists of every maked page view.
The page views counter table contains the same data as the main
page-views
table, but is counted every day, week etc.If page views are requested for a time range that's not available in the counters table, it will be counted and stored. This happens only the first time (unless these values are resetted or recounted).
Caching the values in the
page-views-counter
table could improve the speed for a few milliseconds.Ideas are very welcome!
The text was updated successfully, but these errors were encountered: