Skip to content

Instantly share code, notes, and snippets.

@mekhami
Last active August 4, 2016 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mekhami/d89097002957483dd72dc5630bf31334 to your computer and use it in GitHub Desktop.
Save mekhami/d89097002957483dd72dc5630bf31334 to your computer and use it in GitHub Desktop.
# Cache these for awhile, since they don't change too often. There's no need to hit the DB on every request for this info.
data['is_editor'] = get_or_set_cache("user_{id}_is_editor".format(id=the_user_id), user_in_group, the_user, 1)
data['is_staff'] = get_or_set_cache("user_{id}_is_staff".format(id=the_user_id), the_user.is_staff)
data['is_reviewer'] = get_or_set_cache("user_{id}_is_reviewer".format(id=the_user_id), user_in_group, the_user, group_id_list=[2, 11, 12, 13])
data['is_subscriber'] = get_or_set_cache("user_{id}_is_subscriber".format(id=the_user_id), user_in_group, the_user, group_id_list=[3, 5, 6], timeout=60)
data['can_see_digital_issues'] = get_or_set_cache("user_{id}_can_see_digital".format(id=the_user_id), user_can_see_digital_issues, user=the_user, timeout=60)
data['is_author_services_author'] = get_or_set_cache("user_{id}_is_author_services_author".format(id=the_user_id), is_author_services_author, user=the_user)
data['is_author_services_manager'] = get_or_set_cache("user_{id}_is_author_services_manager".format(id=the_user_id), is_author_services_manager, user=the_user)
data['is_author_services_editor'] = get_or_set_cache("user_{id}_is_author_services_editor".format(id=the_user_id), is_author_services_editor, user=the_user, timeout=300)
data['is_pro'] = get_or_set_cache("user_{id}_is_pro".format(id=the_user_id), is_pro_member, user=the_user, timeout=60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment