Caching paginated results, purging on update - how to solve?

前端 未结 8 1068
忘掉有多难
忘掉有多难 2021-02-04 18:08

I\'ve created a forum, and we\'re implementing an apc and memcache caching solution to save the database some work.

I started implementing the cache layer with keys like

8条回答
  •  半阙折子戏
    2021-02-04 18:41

    In response to flungabunga:

    Another way to implement grouping is to put the group name plus a sequence number into the keys themselves and increment the sequence number to "clear" the group. You store the current valid sequence number for each group in its own key.

    e.g.

    get seqno_mygroup
    23
    
    get mygroup23_mykey
    
    get mygroup23_mykey2
    
    

    Then to "delete" the group simply:

    incr seqno_mygroup
    

    Voila:

    get seqno_mygroup
    24
    
    get mygroup24_mykey
    ...empty
    

    etc..

提交回复
热议问题