Welcome Guest, Not a member yet? Register   Sign In
Like button in my codeigniter website
#4

(08-20-2015, 03:34 PM)sebastianvirlan Wrote: On this category method I have parameters like:
http://website.com/stream/category/art_and_culture
http://website.com/stream/category/busin..._financial
http://website.com/stream/category/auto_and_moto
http://website.com/stream/category/beauty_and_fashion

Ok everything on this page saves in cache in stream+category folder ok?
Imagine that I have 20 categories, each one with 50 pages of 10 questions on each page 
AND ON A SINGLE PRESS OF A LIKE BUTTON EVERYTHING FROM THIS FOLDER stream+category GET DELETED !!!
I think after the like and after deleted that cache the cache for all pages from stream+category will not be builded totally because another like will come and so ...

What can you say about this?

You told me 


Quote:If you're really concerned about excessive deletes in the cache, you could perform the write, but require a minimum age on the existing cache before it gets deleted.

But this would work if in a second 5 users press a like? I think all will mess up .
Instead of deleting all from stream+category folder can I could just delete the file from the folder responsable with the data?

This is why code should be optimized based on your requirements and analysis of the application. If it doesn't make sense to use database caching for this purpose on these pages, then don't use it. You didn't include this information in your original question. Database caching isn't your only option for caching the data, either. You could use the cache library to store the number of likes separately from the database cache that handles the rest of the data on the page(s).

In the worst case, you could probably figure out a method of deleting the correct file for the query if you have to use database caching, but it's not something supported by CI directly.

My point with the minimum age on the cache was this: if you write to the database but only cache the value in the database when the cache is stale, the value in the database will be correct but the value in the cache may be incorrect for a short amount of time. To make sure the cached value doesn't corrupt the database value in the update, you use something like this in your update SQL:
Code:
UPDATE table_likes SET column_likes = column_likes + 1 where id = 2

So, instead of adding one to the cached value and setting that value in an update statement, you tell the database to set the column's value to the current value + 1, and you still don't have to query the database to get the value.
Reply


Messages In This Thread
RE: Like button in my codeigniter website - by mwhitney - 08-24-2015, 07:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB