Exemple #1
0
def get_post(board, num):
  key = "post-%(board)s-%(num)d" % {"board":board, "num":num}
  post = memcache.get(key)

  if post != None:
    logging.info("cache hit")
    return post

  thq = ThreadIndex.all(keys_only=True)
  thq.filter("board", board)
  thq.filter("post_numbers", num)

  thread_idx = thq.get()

  if not thread_idx:
    return 

  thread = db.get(thread_idx.parent())

  [post] = [p for p in thread.posts if p.get('post') == num]

  memcache.set(key, post)

  return post
Exemple #2
0
def index_regen(tkey):
  index = ThreadIndex(parent=tkey, key_name="idx")
  index.put()