def _insert_tag_names_letter(tag_name): #OK """ Insert the tag in the sorted-set of tags by first-letter score. The first-letter-tag sorted set is useful when retrieving all the tags given a letter. Like an index. Safe to duplicates because we set always the same score. """ db.zadd(SEARCH_TAGS_LETTER, ord(tag_name[0].upper()), tag_name)
def _insert_title_ss(title, post_id): # CHANGE - see post UPDATE """ Inserts a title to the sorted set of titles (later on used to find all the posts with the given title), and associates the title with the post id. """ title = title.upper() # pipe = db.pipeline() keys = db.hkeys(title + APPEND_SEARH_POSTS_TITLE_GET_IDS) # We simulate a list of post-ids: the fields of the hash are incremented # by one with each post_id. if keys == None or len(keys) == 0: db.hset(title + APPEND_SEARH_POSTS_TITLE_GET_IDS, "0", str(post_id)) else: db.hset(title + APPEND_SEARH_POSTS_TITLE_GET_IDS, int(max(keys)) + 1, str(post_id)) db.zadd(SEARCH_POSTS_TITLE, 0, title)
def _insert_tag_index_letter_tags(tag): """ Inserts a tag to the index of tag[0] -- tags.""" db.zadd(tag[0].upper() + APPEND_KEY_INDEX_LETTER_TAG, 0, tag)
def _insert_post_user_date_ss(post_id, timedate, username): """ Inserts a post in a user's sorted set of post-ids by date. """ db.zadd(username + APPEND_SEARCH_POST_TIMEDATE, timedate.strftime(FORMAT_TIME_SEARCH), post_id) debug("INSERT sset user_timedate_post_id")