Re: [Cppcms-users] managing caching with lists
Brought to you by:
artyom-beilis
From: Artyom <art...@ya...> - 2011-05-02 07:41:43
|
> From: Andrew <an...@bu...> > > Hi all, > > so I have a table of item records, each of which can be viewed, edited and >updated by id. > > /item/view/{item id} > /item/edit/{item id} > /item/update/{item id} > > I also have a controller that provides a list view > > /list/{page no} > > > managing the caching for the item views is easy enough, I give each page a >trigger that looks like > > cache().add_trigger("item_{item id}") > > and refresh the cache when the item is updated > > cache().rise("item_{item id}") > > > but I am having trouble finding a non-complicated way to > manage the caching of the list view, I have solved it > temporarily by simply refreshing every page > in the list entirely whenever an item is updated, > but ideally I would like to find a simple algorithm that > lets me only refresh the cache for the page on which the > item that has been updated appears. > You have a /list/{page no} item_1, item_2, item_3. for /list/page/1 item_4, item_5, item_6. for /list/page/2 And so on. So for each page you add a trigger just like > because items are ordered by date modified, > and can be added or deleted, which page the > item appears on will change frequently. > > does anyone have a solution that they have found works > for this kind of scenario? > The point is that deleting an item that for example at the top of the list may change all pages i.e. item_1, item_3, item_4, /list/page/1 item_5, item_6, item_7 /list/page/2 So in case of adding new item ore removing new item list rise "list_general" and all pages would be clean and of course add_trigger "list_general" to all the pages. So basically for each page for id in range add_trigger iterm_{id} add_trigger list_general And when you update an item_id on UPDATE id rise(item_{id}) on Add/Delete id rise(item_{id}) rise(list_general) This is how I work with the cache of the blog where multiple pages exist. Of course if the items are added and removed too frequently and you don't want to throw away all the cache you should consider using timeouts and have some not fully consistent cache. > thanks all :) > Best, Artyom > |