2016年9月21日 星期三 晴
网友 Tao给我发了封email,告诉我一个bug,我直到今晚看完《谍影重重5》后才看到,已经快1点了。本来想不管,但最近写代码真的很少,就稍微调试一下,还比较顺利。非常感谢网友Tao。
我翻到下面这页的时候点older,跳到了2014年的博客,这个地方是排序有问题还是什么情况?http://yobin.sinaapp.com/index_prev_page/6/2996/
分析过程:
-
花1分钟复现问题,然后找到相应的url映射,找到对应的处理函数,最后review自己今年写的函数,感觉分页和排序没有问题。
-
也通过后台kvPanel查看kv_artis,发现数据库正常。
[code] def get_page_posts(self, direction = ’next’, page = 1 , base_id = ‘’, limit = EACH_PAGE_POST_NUM): if MYSQL_TO_KVDB_SUPPORT: artilist = self.get_artilist() artilist.reverse() if artilist: basepos = artilist.index(base_id) if direction == ’next’: new_artilist = artilist[basepos+1:basepos+EACH_PAGE_POST_NUM+1] print ‘get_page_posts(), base_id = %s, basepos = %s’ % (base_id,basepos) print new_artilist else: if basepos - EACH_PAGE_POST_NUM < 0: new_artilist = artilist[:EACH_PAGE_POST_NUM] else: new_artilist = artilist[basepos-EACH_PAGE_POST_NUM:basepos] new_artilist.reverse() return post_list_format([self.get_article(id) for id in new_artilist]) [/code]
-
添加了两行print语句,想调试一下,再访问的时候发现后台没打印出调试语句,顿悟是memcache引起的,在博客后台清除了缓存,发现问题不存在了。
-
问题的解决,在AddPost()的地方,修改如下: [code]clear_cache_by_pathlist([’/’, ‘cat:%s’ % quoted_string(post_dic[‘category’]), ‘post_list_index’,])[/code] 改为 [code]clear_all_cache()[/code]
本来只想增加’post_list_index’的cache清除的,后来想想博客程序Tag、Cat、Arches、post_list_tag、微信等Cache太多了,干脆每次更新博客清除一次。EditPost和DelPost暂时不管。
...